You are writing a silly calculator. First, you ask the user to enter an integer. Then you ask them if they would like to know if that number is even, for it to be squared, or for it to be multiplied with another number. The user will input "even" "square" or "multiply" for these options, respectively.
For this question, we do not provide pseudocode -- consult with the sample output to determine how your program should work specifically.
linux3[6]% python3 hw2_part2.py Enter an integer: 34
Would you like to know if this number is even, square it, or multiply it with another number? square
The square of this number is: 1156
linux3[7]% python3 hw2_part2.py Enter an integer: 45
Would you like to know if this number is even, square it, or multiply it with another number? scallop
I don't know what you're talking about.
linux3[8]% python3 hw2_part2.py Enter an integer: 19
Would you like to know if this number is even, square it, or multiply it with another number? even
It is odd!
linux3[9]% python3 hw2_part2.py Enter an integer: 23
Would you like to know if this number is even, square it, or multiply it with another number? multiply
What is the other number? 7
23 times 7 is 161
n = int(input('Enter an integer: ')) choice = input('Would you like to know if this number is even, square it, or multiply it with another number? ') if choice == 'even': if n % 2 == 0: print("It is even!") else: print("It is odd!") elif choice == 'square': print("The square of this number is:", n * n) elif choice == 'multiply': n2 = int(input('What is the other number? ')) print(n, "times", n2, "is", n * n2) else: print("I don't know what you're talking about.")
Get Answers For Free
Most questions answered within 1 hours.