Category Archives: Announcements

Find the largest and the smallest in a set of numbers

Click on the Home tab above.

Today’s discussions:
What is python programming language?

What is computer programming? What is an algorithm?

    You need paper and pen/pencil.

  • Work with a partner to do the following activity: Find the largest and the smallest in a set of numbers.
  • Your teacher will hand you a handful of folded papers with a number on each of them.
  • Open only two papers at a time while the rest of them should stayed folded.
  • minmax5

  • Write down the steps or draw a diagram to show how you calculate both numbers.
  • Switch your paper with a different group.
  • Can you follow the steps? Write comments and suggestions about it.
  • Summarize your strategy in one short paragraph in edmodo.com (You can do this part for homework).

Homework:

  1. Send me an email with your parents email address: the email subject should have student name, class period and class name:
    Example:
    Subject: 6th period – Python – Your Name
  2. Discuss the class policy with your parents.
  3. Visit edmodo.com and reply to the “Introduce yourself” post.

Loops: Compound Interest

Classwork:
CompoundInterest_YI.py: Use a while loop to calculate how many years it would take to have an accumulated total of at least $1,100 at an interest rate of 1.2% when $1,000 is deposited in a savings bank account.

Homework:
CompoundIntTable_YI.py: Use a while loop to show how the investment increases as the accumulated total becomes at least $1,100 at an interest rate of 1.2% when $1,000 is deposited in a savings bank account.

Welcome to THE INVESTMENT TABLE

year  1  interest for this year  12.0  total accumulated up to this year  1012.0
year  2  interest for this year  24.144000000000005  total accumulated up to this year  1024.144
year  3  interest for this year  36.433727999999974  total accumulated up to this year  1036.433728
year  4  interest for this year  48.870932735999986  total accumulated up to this year  1048.870932736
year  5  interest for this year  61.45738392883209  total accumulated up to this year  1061.457383928832
year  6  interest for this year  74.19487253597799  total accumulated up to this year  1074.194872535978
year  7  interest for this year  87.08521100640974  total accumulated up to this year  1087.0852110064097
year  8  interest for this year  100.13023353848666  total accumulated up to this year  1100.1302335384867

Number of years for the investment of $1000 to reach at least a value of $1,100 with an interest rate of 1.2% is  8

Pi Day Activity

Screen Shot 2014-03-13 at 7.53.55 AM
Monday is Pi Day – We will have a pi-day activity ending on Monday
Starting today we are celebrating Pi day by preparing to write a program to do one of the following:
1. Calculate the digits of Pi to highest possible precision
2. Illustrate how Pi is used in a circle.
3. Illustrate how Pi can be applied.
4. Illustrate how Pi was discovered by telling an interactive story.

The programs will be judge based on ingenuity and/or creativity.
NOTE: You can use online resources to help you develop your program. There are good algorithms online. You can not use already written programs.
Include any links used for your resources.

If you like to memorize some of the digits of pi, there will be a competition on Friday. The student who can write the most digits without any help, get a small trophy.

Homework: Explore and investigate the uses and history of pi.
Tomorrow you will tell me what your program you will work on.

Algorithm: Tic-Tac-Toe Functions

February 9th, 2016

Tic Tac Toe program is due on 2/11/16.

Keep in mind programming style tips we have been discussion since the beginning of the year:
1. Documentation: COMMENTS – the header and a short line in each function definition.
2. Naming: use relevant names for variables and functions.
3. Test all possible scenarios to make sure every part of the program executes successfully.

Screen Shot 2016-02-11 at 8.13.56 AM

NOTE: TO MAKE IT MORE INTERESTING AND INVITING TO THE PLAYER, MAKE THE FIRST COMPUTER MOVE RANDOM. However, it should be intelligent once the game is on.

A- 1 day late
B+ 2 days late
B 3 days late
B- 4 days late
C+ 5 days late
C 6 days late
C- 7 days late
D+ 8 days late
D 9 days late
D- 10 days late
F 11 days late
0 after 11 days pass the due date

I encourage you to talk to me ahead of time if this is a problem.

These two functions can be borrowed from the author’s program:


def drawBoard(board):
    # This function prints out the board that it was passed.

    # "board" is a list of 10 strings representing the board (ignore index 0)
    print('   |   |')
    print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
    print('   |   |')
    print('-----------')
    print('   |   |')
    print(' ' + board[4] + ' | ' + board[5] + ' | ' + board[6])
    print('   |   |')
    print('-----------')
    print('   |   |')
    print(' ' + board[1] + ' | ' + board[2] + ' | ' + board[3])
    print('   |   |')

and

def isWinner(bo, le):
    # Given a board and a player's letter, this function returns True if that player has won.
    # We use bo instead of board and le instead of letter so we don't have to type as much.
    return ((bo[7] == le and bo[8] == le and bo[9] == le) or # across the top
    (bo[4] == le and bo[5] == le and bo[6] == le) or # across the middle
    (bo[1] == le and bo[2] == le and bo[3] == le) or # across the bottom
    (bo[7] == le and bo[4] == le and bo[1] == le) or # down the left side
    (bo[8] == le and bo[5] == le and bo[2] == le) or # down the middle
    (bo[9] == le and bo[6] == le and bo[3] == le) or # down the right side
    (bo[7] == le and bo[5] == le and bo[3] == le) or # diagonal
    (bo[9] == le and bo[5] == le and bo[1] == le)) # diagonal

Algorithm: Battleship Day 4

Continuing to prepare for the Battleship program

Classwork:

1. Write the pseudocode to handle checking if there is a ship on one of the edges. What steps would your program follow?

Suggested Classwork:

2. Write a program, Edges4_YI.py to handle the following scenario:

– a hit is found on one of the edges locations on the 3 x 3 board and based on the user’s response write the code to find the ship and sink it.

The idea at every scenario is to find a pattern so you can minimize the code and reuse it.

– Use a list of three lists with 3 items each.
– Randomly select the edges where the program will place the ship.

Screen Shot 2015-02-02 at 7.32.57 AMScreen Shot 2015-02-02 at 8.06.20 AM

Reminder:

Requirements for an A:
1. Don’t forget the introduction with the rules of the game. Let the player know that the ships can only be placed horizontally or vertically.
2. The program has to be turned in on time.
3. The program must have the pygame component.
4. The program has to display at least one board.
5. The program has to handle two ships: 1 of two places and 1 of three places.
6. The program uses a smart algorithm after it finds the first occupied place.
7. The program’s quality of design
8. The program has to run until the game is over.

What will cause a drop in the grade?
The program is not able to tell if the ships overlap.
The program is not able to recognize invalid input.(Prompt the user for valid input)
The program is not able to detect duplicate entries. (Prompt the user for valid input)
The program has no header, no documentation and no output.
The program is over due.

pygame: MazeBouncing_YI.py

Screen Shot 2014-03-10 at 4.30.38 PM

Classwork:
Write a pygame program, MazeBouncing_YI.py. Use the code you learned in animation.py but with a simple maze like the one below.
Screen Shot 2014-03-07 at 9.29.25 AM

Homework:
Visit edmodo.com to answer these questions from Chapter 17.

1. Coming soon.
2. What is 0.2 in the line: time.sleep(0.2)? How is it calculated?
3. What would happen if time.sleep(0.2) was omitted?
4. What would happen if windowSurface.fill(BLACK) was omitted and time.sleep(0.2) is changed to time.sleep(1.0)?

Sean Shypula and Luis Villegas

Next Chapter

Classwork: Modify CollisionDetection program so the bouncer gets bigger when it eats the green food, TheGobbler_YI.py.

Announcement:
Sean Shypula will be visiting PHS today. He will be talking about his journey from high school student to his current life on the “Bungie Farm”. We will welcome Sean in room 242 during periods 6 and 7.
NOTE: make sure your permission slip gets signed by Wednesday.

Screen Shot 2014-03-25 at 9.45.08 AM

Short Bio:
Sean Shypula grew up in Miami, FL and from a young age was fascinated with computers and all things electronic.  In an age before the widespread use of the internet, he managed to teach himself how to write simple programs on his Commodore 64 based upon a few CS books found in a public library, bits of source code found in the back pages of Byte magazine, and a lot of trial and error.  He followed this passion into college earning a degree in Computer Engineering from the University of Florida in 2003.  After college he decided to pursue his true goal of one day being able to make video games for a living, and in 2006 earned a Master’s degree in Computer Science from DigiPen Institute of Technology in Redmond, Washington.  Sean was quickly hired by Bungie Studios, where he has happily been building the studio’s tools and infrastructure ever since.  Sean’s credits include Halo 3, Halo ODST, Halo Reach, and the soon-to-be-released Destiny, which will be the first of a long series of games and the first new franchise for the studio since gaining their independence from Microsoft in 2007.

pygame: PixelArray

Quick announcements: PU students are coming after school today.

This Saturday at PU
splash

Classwork:
Use pixelArray from pygameHelloWorld.py to write the program drawpad_YI.py

drawingpad

# get a pixel array of the surface
pixArray = pygame.PixelArray(windowSurface)
pixArray[480][380] = BLACK

Final Project Proposal and Requirements

Final Project:

SUBMIT A PROPOSAL FOR MY APPROVAL. DO NOT START WORKING ON YOUR PROJECT. IF YOU HAVE INCOMPLETE ASSIGNMENTS, THEY HAVE TO BE FINISHED BEFORE YOU GET STARTED ON YOUR PROJECT BUT TALK TO ME ABOUT THEM.

  • The project can be a game that YOU created.
  • The project can be an application related to business, science, or any other subject you are interested on.
  • The project can be a program that was already assigned but you want to upgrade, modify or expand.
  • The project can be a pygame program or a python program.
  • If it is a pygame program, it must be animated. It must make use of list or dictionary.
  • If it is a python program, it must make use of list or dictionary.
  • The program must have good documentation.
  • The program has to be user friendly.
  • If the program uses other files, compress all of them into one file for submission.
  • Make sure you copy and paste the program on the post.
  • THIS PROJECT IS MEANT TO REPLACE THE WRITTEN FINAL EXAM ONLY IF YOU APPLY YOURSELF.
  • Khan Academy and Breakthrough Prize

    “From now until October 7, Khan Academy and Breakthrough Prize are seeking video submissions that explain a challenging and important concept or theory in mathematics, life sciences, or physics. If you’re between 13 and 18, and you have a passion for explaining ideas and concepts creatively, you can enter the Breakthrough Junior Challenge!
    Learn more about the Breakthrough Junior Challenge
    Not only can you dig into a topic that you’re passionate about, but there are also great prizes to be won, including a $250,000 scholarship for you, a $50,000 award for your teacher, and a state-of-the-art $100,000 science lab for your school. The winner will also be invited California, where the prize will be awarded in front of the superstars of science, Silicon Valley, and Hollywood.

    If you enter, you’ll view and assess other participants’ videos in a peer-to-peer review process. Submissions will then be assessed by leaders in science, technology, and education selected by Khan Academy and by Breakthrough Prize laureates. The judges will select a winner based on how engaging, illuminating, and creative their video is, and how challenging the concept is to understand.

    The deadline for submissions is October 7, so register today at www.breakthroughjuniorchallenge.org. We hope you’ll be inspired to get involved – and share your passion for understanding the world!

    Onward,

    Erin and the Khan Academy content team”

    PROMYS

    PROMYS provides a lively mathematical environment in which ambitious high school students explore the creative world of mathematics. Through their intensive efforts to solve a large assortment of unusually challenging problems in Number Theory, the participants practice the art of mathematical discovery – numerical exploration, formulation and critique of conjectures, and techniques of proof and generalization. More experienced participants may also study The Mathematics of Computer Graphics, Complex Analysis in Number Theory (Dirichlet’s theorem on arithmetic progressions), and Geometry and Symmetry. Problem sets are accompanied by daily lectures given by research mathematicians. In addition, a highly competent staff of 20 undergraduate counselors live in the residence halls and are always available to discuss mathematics with students. Advanced participants also develop independent research projects advised by research mathematicians. Special lectures by outside speakers offer a broad view of mathematics and its role in the sciences and in future career options.

    Screen Shot 2016-01-30 at 1.08.58 AM