Simple Input and Output


Let’s start with output. Command-line Python is oriented towards output. For example, if you type a number in the command line interpreter (i.e., not in the development environment, that we’ll discuss later), Python echoes it. Try to enter any number in the Python workspace and press run button


But it’s best to use print(…). Try to display a number using print() function, for example type:

print(32049)


The simplest input is just using input() function. Let's use any variable s in the example below.
Paste the following snippet in the workspace:

print('Type something then hit "Enter"')
s=input()
print("You entered "+s)


Test Yourself 1.1

Write a program that asks you to input your fisrt name, then asks for your last name and finally prints your full name with a greeting:

first = input('Please type your first name: ')
second = input('Now type your second name: ')
print('Hello, '+first+' '+second)

INTERACTIVE WORKSPACE