Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pyeng Lectures
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Riccardo Caracciolo
Pyeng Lectures
Commits
517a508d
Commit
517a508d
authored
3 months ago
by
Jöran Frey
Browse files
Options
Downloads
Patches
Plain Diff
corrrected error
parent
d1ae15a4
Branches
main
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unit-5/Lifecoding Session/Extra Exercise/Contact Manager.ipynb
+1
-1
1 addition, 1 deletion
...5/Lifecoding Session/Extra Exercise/Contact Manager.ipynb
with
1 addition
and
1 deletion
unit-5/Lifecoding Session/Extra Exercise/Contact Manager.ipynb
+
1
−
1
View file @
517a508d
...
...
@@ -134,7 +134,7 @@
" \"\"\"Main program loop.\"\"\"\n",
" if not login():\n",
" return # Exit the program \n",
" #contin
euse
here if logged in\n",
" #contin
ues
here if logged in\n",
"\n",
" while True: # keeps you in the loop\n",
" #your code\n",
...
...
%% Cell type:markdown id: tags:
# Extra Exercises
%% Cell type:markdown id: tags:
## Build a Contact Manager
Write a Python program that manages a list of contacts. Programm functions that allow a User to add, search, delete, and display contacts.
```
Hint```: the basic framework is already there, you just have to programme the functions
%% Cell type:code id: tags:
```
python
# Contact Manager Program
# List to store contacts with some examples
contacts = [ {"name": "Alice Johnson", "phone": "1234567890", "email": "alice@example.com"},
{"name": "Bob Smith", "phone": "9876543210", "email": "bob.smith@example.com"},
{"name": "Charlie Brown", "phone": "5556667777", "email": "charlie.brown@example.com"},
{"name": "John Do", "phone": "1112223333", "email": "diana.prince@example.com"}]
def display_menu():
"""Displays the menu."""
print("
\n
Contact Manager")
print("1. Add Contact")
print("2. Search Contact")
print("3. Update Contact")
print("4. Display All Contacts")
print("5. Exit")
def add_contact():
print("you chose 1. Add Contact")
def search_contact():
print("you chose 2. Search Contact")
"""Searches for a contact by name."""
def delete_contact():
print("you chose 3. delete a contact")
"""Deletes a contact."""
def display_all_contacts():
print("you chose 4. display all contacts")
"""Displays all contacts."""
def main():
"""Main program loop."""
while True:
display_menu()
choice = input("Enter your choice: ").strip()
if choice == "1":
add_contact()
elif choice == "2":
search_contact()
elif choice == "3":
delete_contact()
elif choice == "4":
display_all_contacts()
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid choice. Please try again.")
# Execute main
main()
```
%% Cell type:markdown id: tags:
## Create a Simple Bank Account System
Build a program that simulates a basic bank account system. Users can deposit, withdraw, and check their balance through a menu-driven interface.
* Add a PIN system to log in (only 3 attempts allowed)
Give the following Functionality
* Check Balance
* Deposit Money
* Withdraw Money
* Exit
```
Hint
```:Use the exercise above as a reference
%% Cell type:code id: tags:
```
python
# choose variables needed
# ... pin balance...
def login():
#your code logic to login, if it returns true your logged in if False you get kicked out (if not login -> return (leave the program)) see main
#your other functions
def main():
"""Main program loop."""
if not login():
return # Exit the program
#contin
euse
here if logged in
#contin
ues
here if logged in
while True: # keeps you in the loop
#your code
#execute main
```
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment