Leaving Cert Notes

Notes and Anki Decks for the Leaving Cert

Inputs

Sometimes we need information from a user

input → program → output

Code using input()

print("What is your name?") # Question on terminal
name = input() # Defines the input
print("Good Morning",name,"What is your PPS number?")

“Good Morning”,name,”What is your PPS number?”

Orange = Print

Green = Called variable made from input

Same Program as Above but Shorted

name = input("What is your name?") # Defines the input
print("Good Morning",name,"What is your PPS number?")

Python always assumes strings, when it comes to input()

How to convert an input to integer

age = int(input("What is your age?"))
print("I am",age,"years old")