#In this program I have compiled some functions and let the user choose which one
#they want to use. The aproach that I took when solving this problem is instead of
#defining the functions first made it so that only the chosen function is defined
# and the others are defined once the user chooses them.
#Prithvi
#In this program instead of defining all of the functions and then giving the commands, I programmed it so each function is only defined after I choose it
while True:
#Here I made it so that all of the functions would be put inside a loop so if 1 ended it would ask you the question again
The_Question = input("what function would you like me to run?")
if The_Question == "prime":
def prime():
number = int(input("Enter The Number"))
# In my primecomposite program I made it so that it was in an infinite loop so that once it ended t would break into the infinite loop again
if number > 1:
for i in range(2,int(number/2)):
if (number % i == 0):
print(number, "is not a Prime Number")
break
else:
print(number,"is a Prime number")
#I added the question to stop and try another function to make the program easier to make it more user friendly
VB = input(" would you like to continue?")
if VB == "yes":
prime()
else:
return
prime()
if The_Question == "calendar":
import calendar
while 8==8:
# by saying "while 8==8" I am creating an infinite loop
#The print_month function is only defined
b = (input("would you like to print out the calendar for a month or a year month/year "))
def print_month():
c = int(input("What year would you like the month to be from. ex. 2020 "))
d = int(input("What month would you like to be printed 1 for january, 2 for febuary etc.. "))
print (calendar.month(c,d))
VB2 = input("would you like to continue")
if VB2 == "yes":
print_month()
else:
return
def print_year():
e = int(input("Which year would you like the calendar be printed of 2015, 2019 etc "))
for i in range(1,13):
print (calendar.month (e,i))
if b == "month":
print_month()
if b == "year":
print_year()
if The_Question == "miles and kilometers":
f = input("Would you like to convert from kiliometer to mile or from mile to kilometer mtk/ktm? ")
if f == "mtk":
miles_question = int(input("How many miles would you like to convert? "))
if f == "ktm":
kilometer_question = int(input("How many miles would you like to convert? "))
def mtk():
res1 = miles_question * 1.608
print(res1,"kilometers")
def ktm():
res2 = kilometer_question * 0.621
print(res2,"miles")
if f == "mtk":
mtk()
if f == "ktm":
ktm()
g = input("would you like to make another conversion? ")
if g == "yes":
0+0
if g == "no":
break
# If the user answers with multiplication that he/she would then need to say if they want a table or just want to multiply 2 numbers.
if The_Question =="multiplication":
MYlist = []
h = (input("would you like to show the multiplication table or would you like to multiply two numbers? table/two_numbers"))
if h == "table":
j = int(input("how many multiplication tables would you like answer 1-10"))
for i in range (0, j):
k = int(input("what multiplication tables do you want 1,2,3 ect."))
MYlist.append(k)
# Once the user is done inputing all of the data, the program appends it all into a list which is needed in the table function
def multtable():
for x in MYlist:
for y in range (1,11):
result = x * y
print(x,"x", y, "=", result)
multtable()
if h == "two_numbers":
def two_numbermultiply():
val3 = val1 * val2
print(val1, " x ", val2," = ", val3)
val1 = int(input("input a number to be multiplied"))
val2 = int(input("input a second number"))
two_numbermultiply()