Skip to content

Instantly share code, notes, and snippets.

@richardbwest
richardbwest / starter1.py
Last active July 19, 2016 08:26
Starter for lesson 2, reviewing lesson 1 learning.
import time,os
input("hello")
time.sleep(1)
os.system("clear")
input("from")
time.sleep(1)
input("clear")
@richardbwest
richardbwest / pythonbasicsstarter2.py
Last active July 19, 2016 09:02
Python Basics Lesson 2 Starter.
import os,time # We need to import these modules in order to use the sleep and system functions later.
os.system('clear')
print("Question 1. Which of the following is the correct code?")
print("\n\n")
print("A. print(hello world) \n")
print("B. Print('hello world)")
print("C. Print('hello world')")
input("\n\nPress enter to see the answer")
time.sleep(1)
name = input("What's your name?")
if name == "Mr West":
print("You're awesome!")
name = input("What's your name?")
if name == "Mr West":
print("You're awesome!")
age = int(input("How old are you?"))
if age > 50:
print("You're ancient!")
age = int(input("Please enter your age: "))
if age < 0 or age > 150:
print("Invalid age!")
@richardbwest
richardbwest / iflistmembershipexample.py
Created July 20, 2016 10:05
A short example of if statements with lists.
answer = input("Do you like Marmite?")
if answer in ["YES","Yes","yes","yep","YEH","y"]:
print("Urgh, you are weird and have no taste buds!")
@richardbwest
richardbwest / schooldayweekendifelse.py
Last active July 20, 2016 10:25
A python script to decide what to do for the day
print("Good morning, I am your wake-up assistant!")
day = input("Is it a schoolday or the weekend?")
if day == "schoolday":
print("You had better get dressed then!")
else:
print("Go back to bed you fool!")
print("Goodbye from me, see you tomorrow!")
@richardbwest
richardbwest / pythoniffollowingcode.py
Last active July 20, 2016 10:26
python if example with following code.py
answer = input("Do you want me to sing a song?")
if answer == "yes":
print("La! la! la! la! la!") #This code is indented!
print("Goodbye!")# This code is not indented!
@richardbwest
richardbwest / breakfastassistantfood.py
Last active July 20, 2016 10:44
A python program to help you choose a breakfast.
choice = input("What do you want to eat?")
if choice == "cereal"):
print("There's milk in the fridge!")
print("We only have corn flakes.")
elif choice in ["tea","coffee"]:
print("You can't just have a drink!")
elif choice == "full english":
print("Ahh, my favourite!")
else:
print("We don't have that, sorry.")