21 Feb Python – Get User Input
With Python, 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:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# student records print("Getting student records from then 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:
1 2 3 4 5 6 7 8 9 10 11 |
Getting student records from 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