Category: Python3

Added: 7th of December 2020

Viewed: 544 times

Learning Python 3, getting basic user input and printing the results

The tutorial presumes you already have Python3 installed on your system. If you don't please visit my other tutorial, How to create a basic Python3 script in Ubuntu and Ubuntu based distributions

The following code takes basic user input in Python 3 and then prints out the results.
Create a new file named user_input.py then copy and paste the code the below.

#!/usr/bin/python3

name = input("what is your name? ")
age = input("how old are you? ")
os = input("What is your favourite programming language? ")

print ("Hello " +name+ " you are ",age," years old. \nYour favourite programming langauge is " +os)


Save the file then enter the following command to make it executable on Linux
chmod +x user_input.py


Then run the file by entering the following in the terminal
./user_input.py

Other Tips & Tutorials

Python3

Learning Python 3, check user input is an integer

Posted: 11th of December 2020

Views: 607

Python3

Learning Python3, Generate a random number using Python3

Posted: 8th of December 2020

Views: 509

Python3

Learning Python 3, getting basic user input and printing the results

Posted: 7th of December 2020

Views: 544

Python3

Learning Python3, System calls on Linux

Posted: 1st of December 2020

Views: 574

Python3

Create a new window using GTK and Python in Ubuntu and Ubuntu based distributions

Posted: 19th of November 2020

Views: 501

Python3

How to create a basic Python3 script in Ubuntu and Ubuntu based distributions

Posted: 28th of April 2020

Views: 980