School club
Log in om je oplossingen te testen.
# School club program
# -------------------------
# Subprograms
# -------------------------
def add_student():
student = input("Enter your name to sign up for the club: ")
student = student + "\n"
file = open("programming.txt", "a")
file.write (student)
file.close()
print("You have been signed up", student)
def show_students():
print("Students that signed up for the programming club:")
file = open("programming.txt", "r")
for student in file:
student = student.strip()
print(student)
file.close()
def menu():
print("1. Sign up")
print("2. Show students")
choice = ""
while choice not in ["1", "2"]:
choice = input("Enter choice: ")
match choice:
case "1":
add_student()
case "2":
show_students()
# -------------------------
# Main program
# -------------------------
menu()
Je kunt zo vaak indienen als je wenst. Er wordt enkel rekening gehouden met je laatst ingediende oplossing.
Log in om je oplossingen te testen.
Python sandbox
In dit venster kan je Python-code uitvoeren zonder iets te moeten installeren. De code die je hier schrijft wordt niet automatisch ingediend in Dodona.