BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Getting Input from User in Python

Last Updated: January 3, 2018 by Chaitanya Singh | Filed Under: Python Examples

In this tutorial, we will see how to take input from user in Python programming language. We use input() function in Python to get user input.

Get String input from user

In this program we will see how to receive string input from user in Python.

# Python Program - Get String Input from User
str = input("Enter any string: ")
print(str)

Output:
Python String Input From User

Get Integer Input from user

As we have seen in the above example that when we receive the input using input() function it is considered as String. To convert the string input to integer we use the int() function over the received input.

# Python Program - Get Integer Input from User
num = int(input("Enter an Integer: "))
print(num)

Output:
Python Int Input User

Get Float Input from user

This is similar to what we have seen above, except that we use float() function to convert the received input into a float value.

# Python Program - Get Float Input from User
num = float(input("Enter a float value: "))
print(num)

Output:
Python Float Value Input

Related Posts:

  1. Get Input from User in Java
  2. Python Program to print Hello World

Top Related Articles:

  1. Python Program to Check if a Number is Positive Negative or Zero
  2. Python Program to Convert Celsius To Fahrenheit and Vice Versa
  3. Python Program to Find ASCII Value of a Character
  4. Python Program to Convert Decimal to Hexadecimal
  5. Python Program to Find Smallest Number in a List

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap