day #8 Taking_User_input_in_python
User - Input
# In python, we can take user input directly by using input() function. this input function gives a return
value as string/character hence we have to pass that into a variables.
ex.
input-
a=input("enter your name: ")
print("my name is", a)
output-
enter your name: harry
my name is harry
# look at this program -
x=input("enter your first number : ")
y=input("enter your second number: ")
print(x+y)
print(int(x)+int(y))
output-
enter your first number : 56
enter your second number: 56
# first answer : 5656
# second answer: 112
# you are expect this program answer is 112 but its not write the real value of 5656
# reason of your computer doesn't understood value or integer value .
# than if we calculate of two, three or many number than i will program- int(integer)
x=int(input("enter your first number: "))
y=int(input("enter your second number: "))
print(x+y)
output-
enter your first number: 45
enter your second number:45
90 #this is perfect number
Comments
Post a Comment