These pictures are from 8-9 years ago!
import random
min = 1
max = 6
roll_again = "yes"
while roll_again == "yes":
print "Rolling the dices..."
print "The values are...."
print random.randint(min, max)
print random.randint(min, max)
roll_again = raw_input("Again? ")
if (roll_again.startswith("never") and
roll_again.endswith("ever")):
print "I didn't want to play anyway."
elif not (roll_again.startswith("no") or
roll_again.startswith("No")):
print "That wasn't an option!"
Interpreted
print "Favourite Animal Test"
prompt = "What is your favourite animal?"
fav = raw_input(prompt)
response = "That is a "
if fav == "dog":
response += "great"
elif fav == "cat":
response += "cool"
elif fav == "dragon":
response += "unreal"
else:
response += "awesome"
response += " choice!"
print response
32 + "abc"
Dynamically Typed
This isn't valid
The Python interpreter evaluates programs line by line
# This will produce some text
ans = raw_input("Pick some letters: ")
# This will produce an integer
ans2 = int(raw_input("Pick some numbers: "))
# You can't add text to an integer, but
# Python will still run the above code
# before failing on this next line
print ans + ans2
# Dynamically typed also means that
# you can do something like this:
stuff = "abc"
stuff = 22
# stuff can be anything you want and
# the Python interpreter will only
# check it when you use it
Types and type systems are a way to provide more information about your code to a program that can check your code automatically.
Program with Types
Type Checker
User
Feedback
Program
Types
Types are checked while the program is running
Types are checked before the program can run