
First the term mentioned above as “User-Input” is nothing but simply taking a value from user side but always remembered that the value that user gives is anything like integers , floating numbers and characters infact boolean(True/False) also.. so let’s start the topic..
Taking input from User…
Delared a variable of your choice. After that use input() function this is the function that takes input from the user until user don’t give any input it will not execute further…
lets see below code…
a = input("Enter the number here: ")
print(a)
above code is run fine but that’s not the way a good coder is always use type casting method now here the question what is type casting method and how does it works don’t worry we will discuss that method in further posts..
for now just copied the below code
# the line below will convert the string into integer..
a = int(input("Enter the number here: "))
print(a)
Note : Input() function takes everythying from user as a string by default if user enter a number it will by default converted into string by input() function so to convert that string into integer we use type casting method here…
A Quick Practice For You Guys…
write the code to take input from user with decimal or string values and print the result..
Leave a Reply