Presentation is loading. Please wait.

Presentation is loading. Please wait.

Python – Input & Output.

Similar presentations


Presentation on theme: "Python – Input & Output."— Presentation transcript:

1 Python – Input & Output

2 Output (to the terminal)
print(“Hello, world!”) # What if we want to output multiple things? print(“hello”, “world!”, 1, 2, 3) # separate with commas

3 Input (via the terminal)
We will use the input() function: input(“prompt”) line = input(“Please enter something:”) print(line) # line is a string

4 Input with numbers (incorrectly)
x = input(“Num 1:”) y = input(“Num 2:”) print(x+y) # What do we see?

5 Input with numbers (correctly)
x = input(“Num 1:”) x = int(x) #convert x to an int y = int(input(“Num 2:”)) #we can also put it all in one line print(x+y) # What do we see?

6 Input with floats x = input(“Num 1:”)
x = float(x) #convert x to an float y = float(input(“Num 2:”)) #we can also put it all in one line print(x+y) # What do we see?


Download ppt "Python – Input & Output."

Similar presentations


Ads by Google