diff --git a/Defining_funtions.py b/Defining_funtions.py new file mode 100644 index 0000000..c78639b --- /dev/null +++ b/Defining_funtions.py @@ -0,0 +1,5 @@ +def hello(name): + print(f'Hello {name}! How are you?') + +username = input('What is your name stranger?\n>') +hello(username) \ No newline at end of file diff --git a/Return_codes_Magic_8_ball.py b/Return_codes_Magic_8_ball.py new file mode 100644 index 0000000..9ead7fb --- /dev/null +++ b/Return_codes_Magic_8_ball.py @@ -0,0 +1,31 @@ +import random + +# This input only makes the user think the program reacts to his question! +# In reality it doesn't do anything! + +input("Ask your question. Be sure it can be answered with a YES or NO!\n>") + +# Define function and based on the evaluation define return code: + +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' + elif random_number == 6: + return 'Mhhh, not sure about that one' + elif random_number == 7: + return "Nope, afraid not" + else: + return "No way in hell" + + +r = random.randint(1,8) +fortune = get_answer(r) +print(fortune) \ No newline at end of file diff --git a/playground.py b/playground.py index 6b5f778..bd7a708 100644 --- a/playground.py +++ b/playground.py @@ -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)