Python User Input Function With Different Data Type
Table of Contents
Python is a interpreter computer programming language. In python there are lot method to get the desired information from the user. In this tutorial I’ll teach you different types input method. Following are the data which use in input function.
- String
- Integer
- Float
- Date
String data type accept the number and alphabetical but you can’t calculate the number.
Integer data type accept the numeric value from the user which can be calculate.
Float Or Double data type is use when you can get the decimal value from the user and its result will be in decimal.
Date data type accept only date value from the users here user only input data value in given input For example 30-11-2020.
User Input Function String
Syntax : value = input (“Please Enter Your First Name”)
>>firstname = str (input (“Please Enter Your First Name :”))
>>lastname = str (input (“Please Enter Your Last Name:”))
>>print (“Full Name : “, firstname + ” ” + lastname )
>>>
User Input Function In Python Integer
In 2nd step we write input function with integer data type in the type the user only bound to write only numeric value in input. The Syntax is..
>> value = int (input (“Please Enter some Number :”))
When you press enter the following line will appear below. You can enter some value and you will see in return.
In this example I write a numeric value 20 and when i call this value he return me the number which i put in input.
How to Calculate Input Integer Value :
In python it is very simple to calculate user integer input value . Following are the step to calculate just follow.
Step 01 : Declare first integer verifiable in input.
Step 02 : Declare 2nd integer verifiable in input.
Step 03 : Declare 3rd integer verifiable to calculate 1st and 2nd number.
Example:
User Input Function In Python Float Value:
How to Declare Float value And Calculate it and get answer by using print function. This syntax is : value = Float (input (“Enter Decimal Number :”))
Step 01 : Declare Float variable in user input
Step 02 : Call float variable in print function
Step 03 : Set the decimal value.
>>marks = float (input (“Enter Your Marks :”))
>>Enter Your Marks :90.4
>> print (“Marks = %.2f” % marks)
Marks = 90.40
Please keep in mind if you wrongly enter the string value in float or integer input the following error will be show.So don’t enter wring value in giver input function.
Note: If you can’t describe the data type in variable the python automatically consider it string value For Example :
value = (Input (“Please Enter Some Text Here :”))
I was suggested this web site by my
cousin. I’m not sure whether this post is written by him as no one else know such
detailed about my trouble.
You are amazing! Thanks!
Thanks brother
Hi there, just became alert to your blog through Google,
and found that it is really informative.
I’m going to watch out for brussels. I’ll
appreciate if you continue this in future.
A lot of people will be benefited from your writing.
Cheers!
thanks
Link exchange is nothing else however it is only placing the other
person’s blog link on
your page at suitable place and other person will also do same for you.
Indihome Jakarta Timur saat ini datang dengan pelayanan pasang
jaringan Indihome lewat cara online, anda tak perlu tiba ke kantor indihome untuk melaksanakan register penempatan indihome.
Ini sebagai wujud pelayanan digital paling depan dari Indihome Jakarta Timur buat membantu warga
Jakarta Timur yang ingin nikmati jaringan internet
cepat indihome. Dengan memakai Technologi Fiber Optik, kami tawarkan sejumlah pelayanan paket internet seperti Singgel Play, Dual Play
juga Triple Play. Disamping itu kami pun menjajakan beberapa Add On Teratas buat anda rasakan sama keluarga.
fantastic as well as incredible blog. I truly wish to thank you, for giving us far
better information.
thank you
Pingback: Free PHP MySQL POS With Source Code 2021 | GSS TECHNOLOGY
Cool blog! Is your theme custom made or did you download
it from somewhere? A design like yours with a few simple tweeks
would really make my blog stand out. Please let me know where you got your
design. Appreciate it
Thank Brother, I customized it