Print statement and input from user
If you want to see the result of declaring variable values in Python program and take input values directly from user in the program. Then here is a simple Python program which shows the example of printing a Python program statement by programmer and taking input from programmer/user in Python program.
# Print a simple statement in Python programming
print(“Hi, welcome to python programming”)
# Print user name
print(“Hi!, Please enter your full name -“)
# Take manual input from user in the program here
user_name = input(“please enter your name “)
# Take input from user and print a message
print(f”Hi, {user_name}! you are welcome to python.”)
In the above Python program script.
print(“Hi!, Please enter your full name -“) The Python program statement prints a message on the console screen.
user_name = input(“please enter your name “) This statement asks the Python programmer to enter his name, and here the user input will be stored in the variable user_name.
Finally, print(f”Hi, {user_name}! you are welcome to python.”) The programmer prints a program statement using the program user input provided by the user.
# Print input statement in Python
print(“let input your age -“)
# Programmer takes direct input from the user
age = input()
# Convert the input variable to integer data type
age = int(age)
# Print a statement using the input
print(f”here You can manual your age {age}.”)
In the above Python program statement.
print(“let input your age -“) The programmer asks the user to input their age and prints a message.
age = input() inputs the age from the programmer/user. It will input the age and print the age on the screen.
age = int(age) int() here converts the input (which is declared in a string) data type to integer format using int function.
print(f”here You can manual your age {age}.”) prints the statements in the console screen based on the input entered by the programmer/user.
A program example for print and user input in Python.
# the below program shows you student name, course, contact and print this information on console screen
# enter student name in console screen
stu_name = input(” enter student name – “)
# enter student course in console screen
course = input(” enter your course detail – “)
# enter student contact in console screen
contact = input(“Please enter your contact – “)
# use int function to Convert string to integer
contact = int(contact)
# let print student name, course, contact information
print(f” student name is” – {stu_name})
print(f” student contact is” -{contact})
print(f” student course is” – {course})
print(“Welcome to python”)