21 Feb Python – Get User Input
With Python, you can easily get user input, instead of hard-coding the values. Similar to Java, C++, and C, Python also supports the concept of user input. The input() method in Python is used to get input from the user.
Let us see a simple example to input student records:
Demo18.py
# student records
print("Getting student records from the user and displaying…")
# student name
sname = input("Enter student name: ")
print("\nStudent Name = " + sname)
# student address
saddr = input("Enter student address: ")
print("\nStudent Address = " + saddr)
# student grade
sgrade = input("Enter student grade: ")
print("\nStudent Grade = " + sgrade)
Output
On running, a user needs to input the records. The Python code displays this input on the screen:
Getting student records from the user and displaying them… Enter student name: Amit Student Name = Amit Enter student address: India Student Address = India Enter student grade: A+ Student Grade = A+
Video Tutorial (English)
Video Tutorial (Hindi)
If you liked the tutorial, spread the word and share the link and our website, Studyopedia, with others.
For Videos, Join Our YouTube Channel: Join Now
Read More:
No Comments