Add functions and return codes

This commit is contained in:
2026-08-25 10:02:56 +02:00
parent ddeeb712d8
commit 4df0cd11d2
3 changed files with 40 additions and 37 deletions

View File

@@ -1,40 +1,7 @@
# def hello():
# # Print 3 greetings:
# print("Good morning!")
# print("Good afternoon!")
# print("Good night!")
# hello()
# hello()
# print('One more time')
# hello()
# def say_hello(name):
# print(f'Hello {name}')
# say_hello('Marc')
import random
def get_answer(random_number):
if random_number == 1:
return 'It is certain!'
elif random_number == 2:
return 'It is decidedly so.'
elif random_number == 3:
return 'Yes'
elif random_number == 4:
return "Doubtful"
elif random_number ==5:
return 'Not likely'
else:
return "No way in hell"
print("Ask a yes or no question:\n>")
input()
r = random.randint(1,5)
fortune = get_answer(r)
print(fortune)
def hello(name):
print(f'Hello {name}! How are you?')
username = input('What is your name stranger?\n>')
hello(username)