# loop practice
def main():
#loop to print even numbers
print "Even Numbers:"
for i in range(5):
even = i * 2
print even
print
# loop to print odd numbers
print "Odd Numbers:"
for i in range(5):
odd = i*2 + 1
print odd
print
#Convert fahrenheit (from lab)
#Write a program that finds the average of a series of numbers entered by the
#user. Ask how many number?, and average should be a float, even if users inputs
ints
def main():
num=eval(input("Enter the count of the numbers to average:")
num=int(num)
sum=0
#BEER ON THE WALL
def main():
for i in range(99, 0, -1):
if i = 1:
print('1 bottle of beer on the wall, 1 bottle of beer!')
print('So take it down, pass it around, no more bottles of beer
on the wall!')
elif i = 2:
print('2 more bottles of beer on the wal
#Ronald Milligan
# Usury.py
#
# Problem: Calulates interest paid on a car loan based on prinicipal and years.
# Certification of Authenticity:
#
I certify that this lab is entirely my own work.
#
I certify that this lab is my own work, but I
#
discussed i
#Accumulating problems
def main():
# print ("Calculates number of siblings")
#
# numLoops = eval(input("Number of people to question: ")
# numSiblings = 0
#
# for i in range(numLoops):
#
siblings = eval(input("Enter number of siblings: ")
#
numSiblings =
# average1.py
# text p. 234
# A program to average a set of numbers.
# Illustrates a counted loop (for loop) with an accumulator.
def main():
n = input("How many numbers do you have? ")
sum = 0.0
for i in range(n):
x = input("Enter a number > ")
sum = sum
# average1.py
# Examples of various loops from text: Zelle.
# All average a set of numbers.
def main():
#Illustrates a counted loop (for loop) with an accumulator.
# n = eval(input("How many numbers do you have? ")
# total = 0.0
# for i in range(n):
#
x =
from graphics import *
import math
#input: circle
#output: color
#purpose: accepts a Circle object and returns the color the circle should be
#filled based on its diameter. Small circles (diameter < 75) are yellow,
#big circles are green
def whichColor(c)
# colorButtons.py
# Creates a white square and several buttons to change the color of the
square
from graphics22 import *
def main():
win = GraphWin("Colorful square", 300, 230)
redButton = Text(Point(50, 150), "Red")
redButton.draw(win)
Rectangle(Point(2
def main():
n=int(input("Please enter a positive integer between 1 and 15: ")
for row in range(1,n+1):
print(*("cfw_:10".format(row*col) for col in range(1, n+1)
main()
#Fibonacci sequence, computs the nth Fib number where n is the value input
#by the user. for example if n=6 then the result is 8.
n=eval(input("Enter a number")
def fibonacci1(n):
if n=1 or n=2:
return 1
return fibonacci1(n-1) + fibonacci1(n-2)
for i in r
#more loops
def main():
print ("Outputs odd numbers between 1 and 20")
for i in range(10):
odd = i * 2 + 1
print (odd)
print ("Outputs even numbers between 1 and 20")
for i in range(10):
even = (i+1) * 2
print (even, end=" ")
print ("\nOutputs even number
# average_time_by_hour.py
#Riley Knudsen
'
answers to T/F, Multiple Choice and Discussion on Chapter 6 (30% of hw grade)
1. F
2. F
3. T
4. T
5. F
6. F
7.F
8. T
9. T
10. F
Multiple Choice
1. b
2. a
3. a
4. b
5. d
6. a
7. d
8. a
9. d
10. a
Reads a data file
"
Lab1.py for the 5 problems assigned in Lab 1
Name: Riley Knudsen
"
def main():
kilometersToMiles()
shootingPercentage()
coffee()
triangleArea()
sphere()
def kilometersToMiles():
"
Compute the number of miles that John will travel, given the
kilometers.
'
state_pop_in_big_cities.py
For chapter 5 do the multiple choice and the discussion questions
Multiple choice
1. d
2.c
3.a
4.c
5.c
6.d
7.d
8.c
9.c
10.a
Discussion
1a.'The Knights who say, ni!'
b. 'spamspamspamni!ni!'
c. 'p'
d. 'pa'
e. 'ani'
f. 'spam!'
g.
'
Discussion questions from Chapter 3
1a. 7.4
1b. 5.0
1c. 8
1d. sqrt is not a math function in pyton
1e. 10
1f. 27
2a. (3 + 4) * 5
2b. n = any number
(n * 2) - n) / 2
2c. n = 3.14
r = any number
4 * n * (r * 2)
2d. r = any number
x = any angle
(r * (cos(x
'
Name: Riley Knudsen
Chapter 4 TF 1-10
1.T
2.T
3.T
4.T
5.F
6.T
7.T
8.T
9.F
10.F
Chapter 4 Multiple Choice 1-9
1.D
2.B
3.D
4.A
5.B
6.D
7.D
8.B
9.B
Purpose: Create a program that allows a 2 people to play a game of tic tac toe
Inputs:
1.Player one clicks t
Computer Science 220
Policies for All Programming Assignments:
Programming assignment grades will be based on elegance and usability as well
as correctness of result.
All identifiers should be meaningful.
Variable names should use lower camel case.
Fu
import random
from Card import Card
class Deck:
def _init_(self, card, num):
self.Card = card
self.num = num
# Shuffles the deck of cards
def shuffle(suit, num):
deck = []
for suit in ['Clubs', 'Diamonds', 'Hearts', 'Spades']:
for num in ['Ace', '2', '3',
Computer Science 220L
Laboratory 3 Arithmetic, Loops
Learning Objectives:
Develop simple Python programs that do input, produce output and do arithmetic
using loops.
Develop simple Python programs that use for loops.
Directed Activities:
0. Download lab
Computer Science 220
Study Guide for Test 2 Spring 2014
Chapter 4 Graphics
What is an object, class, method?
An object is an element or instance of a class. A class describes the contents of
the objects that belong to it. A method is an action which an