-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolutions_Exercise2.py
68 lines (56 loc) · 2.09 KB
/
Solutions_Exercise2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
"""Create a game for FIZZ BUZ and keeping playing with the user untill the user chooses to skip the game"""
def fizz_buzz():
num = int(input("Please enter a number"))
is_inside_if_clause = 'N'
if num%3 == 0 :
print("Fizz",end = ' ' )
is_inside_if_clause = 'Y'
if num%5 == 0 :
print("Buzz")
is_inside_if_clause = 'Y'
if is_inside_if_clause != 'Y':
print("Invalid Input")
"""
Addition/Squaring/exponenation should be done as part of single function named
"my_calculator"
which takes in type of operation, number1,number2 as input
and outputs the answer based on the operation
"""
from function_definitions import *
def my_calculator():
print("****************** MENU ************************")
print("1: Addition")
print("2: Square")
print("3: Exponentation ")
choice = int(input ("Please select your choice"))
if choice == 1 :
first_num = int(input("Please enter First number:"))
second_num = int(input("Please enter Second number:"))
returned_value = my_addition(first_num,second_num)
print("The Addition of the numbers is ",returned_value)
elif choice == 2 :
first_num = int(input("Please enter First number:"))
returned_value = my_square(first_num)
print("The Square of the number is ",returned_value)
elif choice == 3 :
first_num = int(input("Please enter First number:"))
second_num = int(input("Please enter Second number:"))
returned_value = my_exponenation(first_num,second_num)
print("The exponenation of the numbers is ",returned_value)
def play_game():
while(True):
print("Lets Play Fizz Buzz !!!! ")
fizz_buzz()
choice = input("\n Do you want to continue (Y/N)").lower()
if choice == 'n':
break
# function calls
play_game()
def iterative_calculator():
while(True):
print("Lets start !!!! ")
my_calculator()
choice = input("\n Do you want to continue (Y/N)").lower()
if choice == 'n':
break
iterative_calculator()