Category Archives: Uncategorized

Welcome

Welcome to PHS and to a New School Year!!

In this class you will learn the python programming syntax

######################################
#
# Hello World: most popular program ever written!!
# GE
# 9/7/2055
# python 3.x
#
#####################################


print("Hello world")
print("What is your name?")
myName = input()
print("It is good to meet you, " + myName)


##>>> 
##>>> 
##Hello world
##What is your name?
##Alice
##It is good to meet you, Alice
##>>> 

Write programs to run an application like the one below:

A mail-order house sells five products whose retail prices are as follows:  Product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49 and product 5, $6.87. 

Choose from the following:
Product number?: 1
Quantity?: 2
Do you want to continue?(yes/no): yes
Product number?: 2
Quantity?: 5
Do you want to continue?(yes/no): yes
Product number?: 3
Quantity?: 3
Do you want to continue?(yes/no): yes
Product number?: 4
Quantity?: 1
Do you want to continue?(yes/no): no
Total Price: $62

or a program to calculate prime numbers

Up to what number would you like to display all prime numbers? 15
All the prime numbers from 2 to 15 are:
2
3
5
7
11
13

write graphic oriented programs
Screen Shot 2016-09-07 at 1.28.00 PM

and lastly, animations!
atari_pong_anim_np

For loop and random: Whack a Mole

Assignment:
Write a program, whack_a_mole_YI.py to emulate the arcade game.

kitty-whack-a-mole1

Use the random feature of the python math library to randomly select a number between 1 and 3 inclusive.
screen-shot-2016-10-24-at-12-47-48-pm

Prompt the user for a number between 1 and 3.
screen-shot-2016-10-24-at-12-47-34-pm

You whacked the mole if you guess the right number!!
screen-shot-2016-10-24-at-12-47-20-pm

Keep track of how many times you play and how many times you whack the mole and display them as scores with a good message, “Great”, “Not so good”, “Booooo”.

Hint: Can use this code to get you started?

#>import random
#>for i in range(10):
#   print(random.rantint(1,3))
#
#1
#3
#3
#2
#3
#1
#2
#1
#1
#1

List: more advanced concepts in list


more advanced concepts in list

# Creating and accessing tuples.

# retrieve hour, minute and second from user
hour = int( raw_input( "Enter hour: " ) )
minute = int( raw_input( "Enter minute: " ) )
second = int( raw_input( "Enter second: " ) )

currentTime = hour, minute, second   # create tuple

print "The value of currentTime is:", currentTime

# access tuple
print "The number of seconds since midnight is", \
   ( currentTime[ 0 ] * 3600 + currentTime[ 1 ] * 60 +
     currentTime[ 2 ] )


List methods:

listsMethods