Table of Contents

高一義 SciTech

This is a Python Programming course. You can use these places to write Python:

Nov 10

Nov 3

October 27

October 20

October 13

October 6

There was a test today, so, no class.

September 15

Example 1

program-2a.py


import random

n = random.randint(1,2)

print(n)
 

In this program we get a random number. Now, we need to know how to deal with it.

Example 2

program-2b.py


import random

n = random.randint(1,2)

if n == 1:
    print("Heads!")
else:
    print("Tails!")
 

Homework

Here is an example program to help you get started:

program-2c.py


import random

n = random.randint(1,3)

if n == 1:
    print("scissor!")
elif n == 2:
    print("paper!")
else:
    print("stone!)
 

Ok, so what is today's homework?

Todays homework is to write a program that rolls dice. The output must be one of the following six possibilities:

 *

or

*
  
  *

or

*
 *
  *

or

* *
  
* *

or

* *
 *
* *

or

* *
* *
* *

Good luck on today's homework! The answer will be posted next week.

September 8

Today's homework is to write a program that asks for first name and last name and then prints it. Here is an example answer:

sep8.py


a = input("What is your first name? ")
c = input("What is your last name? ")

print ("Hello " + a + " " + c + "!")
 

There are many ways to write the print statement. As long as it is relatively simple and produces the same output it is fine. Another example could be <Code:Python>print(“Hello”, a, c, end=“”); print(“!”) or some method using c+“!”''.