#!/usr/bin/python3 # -*- coding: utf-8 -*- """ Basic keyboard/sccreen I/O """ # Python has a print function print("I'm Python. Nice to meet you!") # => I'm Python. Nice to meet you! # By default, the print function also prints out a newline at the end. # Use the optional argument end="whatever" to change the end string to "whatever". print("Hello, World", end="whatever") print("Hello, World", end="!") # => Hello, World! # To skip the end-of-line newline or character entirely: print("hey", end="") # You can print multiple things, separated by commas: print("hey", "hey") # An optional sep argument defines the character that joins all the printed elements print("hey", "hey", sep="") # This is the default, which you don't need to explicitly request: print("hey", "hey", sep=" ") # input() get's data from standard in (keyboard) print("Type something in:") my_input: str = input() print(my_input) # You can give an optional pre-printed message: my_input: str = input("Type something in:\n") print(my_input) # You can skip storing it in a variable, if you want: print(input("Type something in:\n")) # input() ALWAYS returns the data as a string, event when you type a number. my_input: str = input("Type in a number") print(my_input) print(type(my_input)) my_input: int = int(input("Type in a number")) print(my_input) print(type(my_input)) # Note: In earlier versions of Python (2), # input() method was named as raw_input() # Python2 is effectively dead; don't use it...