My goal is to carry out the instructions below:
Enter integer:
4
You entered: 4
4 squared is 16
And 4 cubed is 64 !!
Enter another integer: 5
4 + 5 is 9
4 * 5 is 20
Here are my codes:
user_num = int(input('Enter integer:\n'))
print("You entered: ", user_num)
print(user_num, "squared is ", user_num*user_num)
print("And", user_num, "cubed is", user_numuser_numuser_num, "!!")
user_num2 = int(input("Enter another integer:\n"))
print(str(user_num) + str(user_num2), "is", user_num+user_num2)
print(str(user_num) * str(user_num2), "is", user_num*user_num2)
The problem is that the last two lines of my codes are not giving me what I want. I want the inputs for user_num and user_num2 to be printed in a non-concatenated way and without execution to read, for example, "4 + 3 is 7" and "4 * 3 is 12". Any help will be greatly appreciated. Thanks
https://stackoverflow.com/questions/65866998/how-to-print-variable-inputs-with-operators-in-python January 24, 2021 at 11:57AM
没有评论:
发表评论