how to input a integer in python code example
Example 1: python input integer
# To prompt the user to input an integer we do the following:
valid = False
while not valid: #loop until the user enters a valid int
try:
x = int(input('Enter an integer: '))
valid = True #if this point is reached, x is a valid int
except ValueError:
print('Please only input digits')
Example 2: How do you print a integer in python
x = 7
print('Number: ' + str(x))
#str() turns anything inside to a string which allows you to
#add it to another/different string
Example 3: user input of int type in python
#python program
#taking int input from user
#printing them
#num1 from user
num1 = int(input("Enter a number of type int"))
print(num1)
Example 4: print(10**2//-3)
print(10**2//-3)
-34