Getting Input In Python.
Getting input.
The input Function is simple way for your program to get input from Users.. We can take any type of input from users. To take input first we need to declare its Data types. It is simple to declare data-types in Python. Let's see a simple example.
1. Example to take name of user and print it.
name=eval(input("Enter your name"))
print("Hello", name)
>> output >>
>> Enter your name
>> Google
>> Hello Google
2. Example to find square of given number.
num=int(input("Enter number to find square"))
print("The square of", num, "is", num*num)
>> output >>
>> Enter number to find square >> 7
>> 49
In above program the key point is that, If we want integer value then we write (int) to get input and (eval) to get String input. We also write (input) only. One of the nice feature to use (eval) is we provide the expression like (3*12+5).
1.python variable:👇👇👇
https://programmingcompute.blogspot.com/2020/12/python-variable.html
The input Function is simple way for your program to get input from Users.. We can take any type of input from users. To take input first we need to declare its Data types. It is simple to declare data-types in Python. Let's see a simple example.
1. Example to take name of user and print it.
name=eval(input("Enter your name"))
print("Hello", name)
>> output >>
>> Enter your name
>> Google
>> Hello Google
1. Example to take name of user and print it.
name=eval(input("Enter your name"))
print("Hello", name)
>> output >>
>> Enter your name
>> Hello Google
2. Example to find square of given number.
num=int(input("Enter number to find square"))
print("The square of", num, "is", num*num)
>> output >>
>> Enter number to find square >> 7
>> 49
In above program the key point is that, If we want integer value then we write (int) to get input and (eval) to get String input. We also write (input) only. One of the nice feature to use (eval) is we provide the expression like (3*12+5).
num=int(input("Enter number to find square"))
print("The square of", num, "is", num*num)
>> output >>
>> Enter number to find square >> 7
>> 49
In above program the key point is that, If we want integer value then we write (int) to get input and (eval) to get String input. We also write (input) only. One of the nice feature to use (eval) is we provide the expression like (3*12+5).
1.python variable:👇👇👇
https://programmingcompute.blogspot.com/2020/12/python-variable.html
Comments
Post a Comment