Enter value from command prompt in python

Place value from command prompt in python

Enter the value in python program from command prompt:

# Accept a string input from the user
name = input("Enter your name: ")

# Print a greeting using the input value
print("Hello, " + name + "!")

Note: input() function always returns a string value, so you may need to convert it to a different data type if you need to use it in numeric calculations or other operations. You can do this using the appropriate conversion function, such as int() or float().

Run the as python program and save as py extention.

C:\Users\ersan\Desktop>python 1.py
Enter your name: RAKESH
Hello, RAKESH!

1 thought on “Enter value from command prompt in python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.