Python Programming

This course will introduce students computer science and writing code.  We will study data types, logic, loops, input/output and functions.  We will use this knowledge to write our own interactive games on the computer.

I am here by 7:00 every day, and am also available after school. Please see me if you need extra help or have any questions or concerns. You can also email me at:

cporter@brunswick.k12.me.us.

I’m looking forward to a challenging and productive semester.

1/23/18 Assignment 0:  Code a “header” program that prints your name and pertinent information on the screen.

1/25/18 Assignment 1:  Write code to print at least 3 “block” letters using text.

               Assignment 2:  Write a program that allows the user to enter two integer variables      and print out the sum, difference, product, real number division, integer quotient and integer remainder.

1/29/18 If, if..else, if..elif..else and Boolean variables.  Quiz on Friday

Assignment 3:  Code a program that allows the user to choose whether to convert Fahrenheit to Celcius or Celcius to Fahrenheit, and then allow the user to enter the temperature and convert it to the other scale.  Be sure to test your code with known values, like 212 f to 100 c.

C = (F – 32)*5/9

F = 9/5*C +32

 

 

 

 

 

 

 

 

 

 

 

9/7/17 Intro to Python

Assignment 1:  Code a function to print out an introductory header for your programs.  Be sure to “call” (implement) the function in the main body of your program.

9/11/17 Variables, user input and arithmetic operations

Assignment 2:  Code and run a program that allows the user to enter two numerical values and prints the sum, difference, product, real number quotient, integer quotient and integer remainder.  Be sure to practice integer division for quotient and remainder with negative numbers.  You may also include your header in this and subsequent programs.

9/13/17 Boolean types, if..elif..else statements.

Assignment 3:  Code a program that allows the user to choose whether to convert Fahrenheit to Celcius or Celcius to Fahrenheit, and then allow the user to enter the temperature and convert it to the other scale.  Be sure to test your code with various values, like 0,100,32,212 and -40!

9/15/17 Boolean operators and the”while” loop.  Quiz on Tuesday

Assignment 4:  Rewrite assignment 3 to use functions to do the calculations.  Define a function for F_to_C and one for C_to_F.  Allow the user to repeat the conversions using a “while” loop.

9/19/17 Quiz 1.1. Review how to initialize and index a counter, the while loop and boolean operators.

Assignment 5:  Code a number guessing game.  The program will prompt the user to enter an integer, give feedback as to whether the guess is too high or too low, and finally print out the number of guesses it took for the user to correctly guess the number.

9/21/17 Random number generator

Assignment 6:  Modify assignment 5 to include:   1)Use a random number.  2) Allow the user to enter the lower and upper bound for the range of numbers

DO NOT get rid of program #5, but modify it, and save it with a new name.

9/25/17 The “for” loop.

Program 7- The Fibonacci Sequence      1,1,2,3,5,8,13,21,34… The next number is the sum of the previous 2 numbers.

Write code to print the first 20 Fibonacci numbers and the Golden Ratio for each number.

9/27/17 Nested for loops.  

Program 8 Write code to determine the abundant numbers from 1 to 100.

In number theory, an abundant number or excessive number is a number for which the sum of its proper divisors is greater than the number itself. The integer 12 is the first abundant number. Its proper divisors are 1, 2, 3, 4 and 6 for a total of 16. The amount by which the sum exceeds the number is the abundance. The number 12 has an abundance of 4, for example.

9/29/17 Start looking at strings.

Program 9:  Use a string variable, assign it a value of “test string”.  Reassign your string variable so it prints out “String test”.  Then run through the string and print out only vowels.

10/3/17 More string stuff.

Program 10: Write a function named replace_at_index that takes a string and an integer. The function should return a new string that is the same as the old string, EXCEPT with a dash in place of whatever character was at the index indicated by the integer.

Call your function on the word eggplant and the index 0, like this:

s = replace_at_index(“eggplant”, 0)

You should then print the value of s, which should display:

-ggplant

10/5/17 Quiz 2

10/11 Start Turtle graphics.  Use import turtle

Program 11: Write a program to print a square of a given size starting at some point (x,y).  Use the following function definition:

def draw_square(x,y,side_length):

10/19 Program 12- Use your imagination and creativity to draw something cool.

10/23 Work on program 12.  Quarter 1 test on Friday.