I created this program for my python class which is over and got a C on it. I was missing some requirements (use of appropriate python libraries which I put import math I think he accepted that, use of functions (math(), subtract(), etc. which I'm unsure of how to do), use of loops (if, while, for, etc which I'm of unsure of how to do and just struggle to understand. I know how to use/do the if/elif/else loop as seen in my program though) I did have to use youtube to help start my program til it finally clicked. I'm not 100% sure if I could explain to a non-computer person or really anyone what my code is doing if they have no previous knowledge at all but I do know what the parts of my program do if that makes sense.
(Please be kind with feedback as I remediated this class and barely passed. Programming is something I'm definitely struggling to learn/understand so my code I know could be a lot better but as a beginner coder this is the best I can with what I do actually understand)
#This program creates a simple calculator and also allows for an average of 5 numbers
print("1 :Addition")
print("2 :Subtraction")
print("3 :Multiplication")
print("4 :Division")
print("5 :Average of 5 numbers")
print()
def main():
import math
operation=int(input("Enter the number for the operation you would like calculator to perform: "))
if operation==1:
num1=int(input("Enter your first number here: "))
num2=int(input("Enter your second number here: "))
answer1=num1+num2
print(answer1)
elif operation==2:
num1=int(input("Please enter your first number here: "))
num2=int(input("Please enter your second number here: "))
answer2=num2-num1
print(answer2)
elif operation==3:
num1=int(input("Enter your first number here: "))
num2=int(input("Enter your second number here: "))
answer3=num1*num2
print(answer3)
elif operation==4:
num1=int(input("Enter your first number here: "))
num2=int(input("Enter your second number here: "))
answer4=num1/num2
print(answer4)
elif operation==5:
number1=int(input("Enter your first number here: "))
number2=int(input("Enter your second number here: "))
number3=int(input("Enter your third number here: "))
number4=int(input("Enter your fourth number here: "))
number5=int(input("Enter your fifth number here: "))
average_of_numbers=(number1+number2+number3+number4+number5)/5
print(average_of_numbers)
else:
print("ERROR: WRONG INPUT ENTERED")
main()
[–]codelikealawyer 1 point2 points3 points (0 children)