0% found this document useful (0 votes)
42 views1 page

Introduction To Coding Python Reference Sheet

This document is a reference sheet for introductory Python programming, covering various topics such as displaying text, user input, conditional statements, and using color and style in output. It includes examples of code snippets for password input, greeting users, and formatting text with colors and styles. Additionally, it demonstrates the use of multiple if statements and goto loops for repeating code.

Uploaded by

phoebe.bright
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views1 page

Introduction To Coding Python Reference Sheet

This document is a reference sheet for introductory Python programming, covering various topics such as displaying text, user input, conditional statements, and using color and style in output. It includes examples of code snippets for password input, greeting users, and formatting text with colors and styles. Additionally, it demonstrates the use of multiple if statements and goto loops for repeating code.

Uploaded by

phoebe.bright
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Introductory Python # the csinsc module

# needed for goto


Reference Sheet label .ask_again
password = input("Enter password:")

Displaying Text on the Screen


if password != "letmein":
print("Hello, world!")
print("Incorrect, try again.")
goto .ask_again

Pausing Until the User Presses [ENTER] to


print("Welcome inside!")
Continue
input("Press [Enter] to continue")
Displaying Text in Colour
from csinsc import * # using code from
Comments
# the csinsc module
# These are comments, everything after # needed for colour
# the hash sign is ignored by Python
print(Colour.red + "In red.")
print(Colour.blue + "In blue.")
Letting the User Enter Text, Displaying it to
print(Highlight.blue + "Blue highlight.")
the Screen
print(Highlight.cyan + "Cyan highlight.")
name = input("Please enter your name:") print(Style.bold + "In bold.")
print(Style.underline + "Underlined.")
print("Hi, " + name + ", how are you?") print(Colour.reset + "Back to normal.")

print(Colour.red + Highlight.blue + Style.bold +


Making a Decision with an if Statement
"Combined red text, blue highlight and bolded!")
if name == "Joan":
print("My name is Joan too!")
print("Have a nice day!") Colour and Style Guide
Colour.red Highlight.red
# Note:"Have a nice day!" is always shown Colour.orange Highlight.orange
# because it is not part of the IF Colour.yellow Highlight.yellow
# code block Colour.green Highlight.green
Colour.cyan Highlight.cyan
Colour.blue Highlight.blue
Not Equals with an if Statement
Colour.purple Highlight.purple
if name != "Tom": Colour.magenta Highlight.magenta
print("Have you seen Tom, btw?") Colour.white Highlight.white
Colour.grey Highlight.grey
Style.bold Style.underline
Multiple if Statements
if name == "Joan":
print("My name is Joan too!")
if name == "John":
print("My brother's name is John.")
if name == "Hugo":
print("My best friend is called Hugo.")
print("Bye now!")

Repeating Code (goto Loops)


from csinsc import * # using code from

You might also like