Skip to content
Snippets Groups Projects
Commit 517a508d authored by Jöran Frey's avatar Jöran Frey
Browse files

corrrected error

parent d1ae15a4
Branches main
No related tags found
No related merge requests found
%% 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("\nContact 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
#contineuse here if logged in
#continues here if logged in
while True: # keeps you in the loop
#your code
#execute main
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment