Table of Contents

PySPS

Introduction

A Version of this is in Basics II, so the intent of this is to represent a Basics I and II approach for older kids or people with experience. Still, it is best used as a 'second class' once they know some basic data types.

Teaching Ideas

The basics is that they need to understand integers, if, print and input. You can start by asking them to input their name and then printing a message based on IF statements. Maybe do a password program. This is the essential basic I. Then you introduce random numbers. Once they have that, they have almost everything for scissor, paper, stone. The music, I added at the end to show them what is possible, but you don't need to add that.

Dictionaries

I used a dictionary here but originally it was just strings (and with more IFs). Since I had taught them what a dictionary was in a previous class

The Code

# Import random because we need random numbers.
import pygame
import random

pygame.mixer.init()
pygame.mixer.music.load("music2.mp3")
pygame.mixer.music.play()


# Step 1: Ask for scissor, paper or stone.
print(" ==========================")
print(" Scissor, Paper, Stone v1.0")
print("        by: Appledog")
print(" ==========================")
print("")

print(" Choose your option!")
print("")
print(" a) Scissor")
print(" b) Paper")
print(" c) Stone")
print("")

a = input(" > ")

# Step 2: Computer will choose
sps = { 'a':'scissor', 'b':'paper', 'c':'stone' }
b = random.choice(['a', 'b', 'c'])

# Step 3: Show what the choices are.
print("You choose: " + sps[a])
print("Computer choose: " + sps[b])

# Step 4: Who wins?
if a == b:
    print("tie!")

elif sps[a] == 'scissor' and sps[b] == 'paper':
    print("You win!")

elif sps[a] == 'paper' and sps[b] == 'stone':
    print("You win!")

elif sps[a] == 'stone' and sps[b] == 'scissor':
    print("You win!")

else:
    print("You lose!")