WSQ03-Fun with numbers

1 min read

#WSQ03 #TC1014

this time the program has to ask the user for two integers and calculate sum, difference, product, division (no decimals) and remainder.

lets start with the input function so we can enter the numbers for the operations. use a variable like “x” and write this:

x = int(input())  

also you can add text in the input function to tell the user what you want him to input:

x = int(input(“enter an integer: “)

repeat the line with another variable like “y” 

y = int(input(“enter an integer: “)

now let’s start with the calculations, set a different variable for each one and the rigth operators: 

+, -, *, / and %

example: a = x+y

if you didn’t used the “int” function it won’t add them like 1+2=3 but it would go like this 1+2=12. that was my problem when writing the line.

finish the rest of the operations and then the print function:

print (a)  ——here goes the variable you want to print.

and thats it.

CC BY 4.0 WSQ03-Fun with numbers by sergio is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.