Hello everyone,
I have a homework assignment where we are supposed to make a basic arithmetics calculator using:
• Lists
• Built-in functions including split(), upper(), len()etc.
• in, not in, == etc. operators
• String manipulation
• Conditional statements (if-elif-else)
• Iterative statements (while)
also
We cannot use the built-in functions eval( ) or exec().
We cannot use break or continue or pass or sys.exit( ) in our Python program.
I'm having difficulties with 2 things:
1) How to end a while loop without using break, our teacher suggested using
carryON = True
# Loop until the user has entered either ‘Q’ or ‘q’
while carryON :
but I don't know how to make the statement False
2) How to add the users values from a list
So far I have:
Ex: [Add, 5, and, 3]
Thank you!
I have a homework assignment where we are supposed to make a basic arithmetics calculator using:
• Lists
• Built-in functions including split(), upper(), len()etc.
• in, not in, == etc. operators
• String manipulation
• Conditional statements (if-elif-else)
• Iterative statements (while)
also
We cannot use the built-in functions eval( ) or exec().
We cannot use break or continue or pass or sys.exit( ) in our Python program.
I'm having difficulties with 2 things:
1) How to end a while loop without using break, our teacher suggested using
carryON = True
# Loop until the user has entered either ‘Q’ or ‘q’
while carryON :
but I don't know how to make the statement False
2) How to add the users values from a list
So far I have:
print("Select operation:") print(" Add by using the statement: Add N1 and N2") print(" Subtract by using the statement: Sub N2 from N1") print(" Multiply by using the statment: Mul N1 by N2") print(" Divide by using the statment: Div N1 by N2") print(" Or to Exit enter: Q") #Ask user for input and display approprite message operation=input("Enter an arithmetic statement or 'Q' to quit the calculator: ").split() sum = print ("Answer: " +operation[0]+" "+operation[1]+" "+operation[2]+" "+operation[3]+ " = " + (sum))So if I want to add the values of operation 1&3 how would I do that?
Ex: [Add, 5, and, 3]
Thank you!