Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3f10b35
Completed Chapter 1
JasonC07 Nov 2, 2017
d77ff94
Completed Chapter 3
JasonC07 Nov 6, 2017
162fa38
Completed Chapter 4
JasonC07 Nov 9, 2017
b926a9e
Merge branch 'master' of https://github.com/LewisAndClark-CSD/program…
JasonC07 Nov 14, 2017
6115ca3
Completed Questions 1-5.
JasonC07 Nov 14, 2017
cf55575
Completed Chapter 6 worksheet.
JasonC07 Nov 15, 2017
f851b1d
first attempt
JasonC07 Nov 15, 2017
b84bed2
Success
JasonC07 Nov 15, 2017
b1f9bdd
Completed Chapter 6 Lab part 1
JasonC07 Nov 15, 2017
94e9171
Forgot to do a commit but Completed Chapter 6 Lab part 2
JasonC07 Nov 15, 2017
38f5b29
Completed worksheet 5
JasonC07 Nov 16, 2017
86dba09
First commit of part 4
JasonC07 Nov 16, 2017
112b290
Trouble with y_offset
JasonC07 Nov 16, 2017
c34d826
Got it to print little rectangles in a box but not large enough for grid
JasonC07 Nov 16, 2017
29468bd
Completed Chapter 6 part 4
JasonC07 Nov 16, 2017
7c0bba5
Completed worksheet of chpater 7.
JasonC07 Nov 20, 2017
e8fb85b
First commit of Lab 7
JasonC07 Nov 20, 2017
ae9e9d4
Tried to run program didn't go well
JasonC07 Nov 20, 2017
8185a77
Made the room list so rooms hook up according to the room closest to …
JasonC07 Nov 20, 2017
e7233db
Finished room variable I believe.
JasonC07 Nov 20, 2017
b63fbeb
Help from teacher and testing.
JasonC07 Nov 28, 2017
c090f19
Added descriptions of rooms.
JasonC07 Nov 28, 2017
eaa2acf
Testing
JasonC07 Nov 28, 2017
2734d8e
Added room_list.append for balcony
JasonC07 Nov 28, 2017
5c73dad
Chopped a bit of the line that was too long.
JasonC07 Nov 28, 2017
d562e8e
Made a way for the user to exit the program
JasonC07 Nov 28, 2017
794647f
Completed Lab 7
JasonC07 Nov 29, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Lab 01 - Calculator/lab_01_part_a.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#
#1.1 part A
Fahrenheit = int(input("Enter temperature in Fahrenheit: "))
Celsius = (Fahrenheit - 32)*5/9
print("The temperature in Celsius:",Celsius)
6 changes: 5 additions & 1 deletion Lab 01 - Calculator/lab_01_part_b.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#
# 1.2 Part B
height = int(input("Enter the height of the trapezoid: "))
base = int(input("Enter the length of the bottom base: "))
top = int(input("Enter the length of the top base: "))
print("The area is: ", ((top + base) * height) / 2)
5 changes: 4 additions & 1 deletion Lab 01 - Calculator/lab_01_part_c.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
#
#1.3 Part C
problem = int(input("Enter the radius: "))
circle = 3.14 * problem**2
print(circle)
37 changes: 36 additions & 1 deletion Lab 03 - Create a Quiz/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
#
#This will be a quiz.
question_1 = input("1. What is Master Chief's name? ")
correct = 0
incorrect = 0
if question_1 == "John":
correct += 1
print("Correct.")
else:
print("Incorrect.")
question_2 = int(input("2. What is Master Chief's service tag number? "))
if question_2 == 117:
correct += 1
print("Correct.")
else:
print("Incorrect.")
question_3 = input("3. What is Master Chief's partner's name? ")
if question_3 == "Cortana":
correct = correct + 1
print("Correct.")
else:
print("Incorrect.")
question_4 = input("4. Who is the Master Chief uneasy allies with? ")
if question_4 == "Arbiter":
correct += 1
print("Correct.")
else:
print("Incorrect.")
question_5 = input("5. What is the name of Master Chief's armor? ")
if question_5 == "MJOLNIR":
correct += 1
print("Correct.")
else:
print("Incorrect.")

print("You got", correct, "right.")
print("Your score was", (correct/5)*100)
99 changes: 98 additions & 1 deletion Lab 04 - Camel/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,98 @@
#
import random

print("Welcome to Camel!")
print("""You have stolen a camel to make your way across the great Mobi desert.
The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.""")
print()

#variables
oasis = 100
milesTraveled = 0
thirst = 0
camelFatigue = 0
nativesTraveled = -20
canteen = 3
done = False


#start main loop
while not done:
nativesBehind = milesTraveled - nativesTraveled
fullSpeed = random.randrange(10, 21)
moderateSpeed = random.randrange(5, 13)
print("""
A. Drink from your canteen.
B. Ahead at moderate speed.
C. Ahead full speed.
D. Stop for the night.
E. Status check
Q. Quit.""")
print()
userInput = input("Your choice? ")
if userInput.lower() == "q":
done = True

#status
elif userInput.lower() == "e":
print("Miles traveled: ",milesTraveled)
print("Drinks in canteen: ",canteen)
print("Your camel has ",camelFatigue,"amount of fatigue.")
print("The natives are ",nativesBehind,"miles behind you.")
#stop for night
elif userInput.lower() == "d":
camelFatigue *= 0
print("Your camel feels refreshed and happy his fatigue is now ",camelFatigue)
nativesTraveled += random.randrange(7, 15)
#move full speed
elif userInput.lower() == "c":
print("You traveled ",fullSpeed,"miles!")
milesTraveled += fullSpeed
thirst += 1
camelFatigue += random.randrange(1, 4)
nativesTraveled += random.randrange(7, 15)
oasis = random.randrange(1, 21)

#move moderate speed
elif userInput.lower() == "b":
print("You traveled ",moderateSpeed,"miles!")
milesTraveled += moderateSpeed
thirst += 1
camelFatigue += 1
nativesTraveled += random.randrange(7, 15)
oasis = random.randrange(1, 21)

#drink canteen
elif userInput.lower() == "a":
if canteen == 0:
print("You're out of water.")
else:
canteen -= 1
thirst *= 0
print("You have ",canteen,"drinks left and you are no longer thirsty.")

#not done check
if oasis == 20:
camelFatigue *= 0
thirst *= 0
canteen = 3
print("You found an oasis! After taking a drink you filled your canteen and the camel is refreshed.")
if nativesBehind <= 15:
print("The natives are drawing near!")
if milesTraveled >= 200 and not done:
print("You made it across the desert, you win!")
done = True
if nativesTraveled >= milesTraveled:
print("The natives caught and beheaded you.")
print("You're dead!")
done = True
if thirst > 4 and thirst <= 6 and not done:
print("You are thirsty")
if thirst > 6:
print("You died of dehydration!")
done = True
if camelFatigue > 5 and camelFatigue <= 8 and not done:
print("Your camel is getting tired.")
if camelFatigue > 8:
print("Your camel is dead.")
done = True

24 changes: 23 additions & 1 deletion Lab 05 - Create a Picture/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
#
#Create an empty array called room_list
room_list = []

#Create a variable called room with an array of five elements.
room = [4]
#First element create a string with description of the first room.

#Other four will be number of the next room if user goes north, south, east, or west.

#Make sure to write which number connects to which other.

#If there isn't one at a location like none at the west then write None but NOT in quotes.

#Append the room to the room list

#Repeat the prior two steps for each foom you want to create.

#Re-use the room variable

#Make new variable called current_room set it to zero.
current_room = 0
#print the room_list variable run the program to test it.
print(room_list)
13 changes: 13 additions & 0 deletions Lab 06 - Loopy Lab/part_1.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
#Set a variable to ten
counter = 10

#Repeat nine times
for i in range(9):


#Loop to print numbers in a line
for j in range(i + 1):
print(counter, end=" ")
#increatment the number
counter += 1
#print new line
print()
68 changes: 67 additions & 1 deletion Lab 06 - Loopy Lab/part_2.py
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
#
"""
Pygame base template for opening a window

Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/

Explanation video: http://youtu.be/vRB_983kUMc
"""

import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

pygame.init()

# Set the width and height of the screen [width, height]
size = (500, 500)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("My Game")

# Loop until the user clicks the close button.
done = False

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
# --- Main event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

# --- Game logic should go here

# --- Screen-clearing code goes here

# Here, we clear the screen to white. Don't put other drawing commands
# above this, or they will be erased with this command.

# If you want a background image, replace this clear with blit'ing the
# background image.
screen.fill(WHITE)

# --- Drawing code should go here
y_offset = 0
for x in range(1, 20):
y_offset += 50
x_offset = 50
for y in range(1, 20):
pygame.draw.circle(screen, RED, [x_offset,y_offset], 10, 5)
x_offset += 50
# --- Go ahead and update the screen with what we've drawn.
pygame.display.flip()

# --- Limit to 60 frames per second
clock.tick(60)

# Close the window and quit.
pygame.quit()
68 changes: 67 additions & 1 deletion Lab 06 - Loopy Lab/part_4.py
Original file line number Diff line number Diff line change
@@ -1 +1,67 @@
#
"""
Pygame base template for opening a window

Sample Python/Pygame Programs
Simpson College Computer Science
http://programarcadegames.com/
http://simpson.edu/computer-science/

Explanation video: http://youtu.be/vRB_983kUMc
"""

import pygame

# Define some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)

pygame.init()

# Set the width and height of the screen [width, height]
size = (500, 500)
screen = pygame.display.set_mode(size)

pygame.display.set_caption("My Game")

# Loop until the user clicks the close button.
done = False

# Used to manage how fast the screen updates
clock = pygame.time.Clock()

# -------- Main Program Loop -----------
while not done:
# --- Main event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True

# --- Game logic should go here

# --- Screen-clearing code goes here

# Here, we clear the screen to white. Don't put other drawing commands
# above this, or they will be erased with this command.

# If you want a background image, replace this clear with blit'ing the
# background image.
screen.fill(WHITE)

# --- Drawing code should go here
y_offset = 0
for x in range(1, 20):
y_offset += 50
x_offset = 50
for y in range(1, 20):
pygame.draw.circle(screen, RED, [x_offset,y_offset], 10, 5)
x_offset += 50
# --- Go ahead and update the screen with what we've drawn.
pygame.display.flip()

# --- Limit to 60 frames per second
clock.tick(60)

# Close the window and quit.
pygame.quit()
62 changes: 61 additions & 1 deletion Lab 07 - Adventure/main_program.py
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
#
#!/usr/bin/env python3
#Adventure.py
#Jason Cobb
#11/28/17

#Create an empty array called room_list
room_list = []

#Create a variable called room with an array of five elements.
room = ["the North hall pictures of angels fighting demons line the walls.", None, 4, 3, 1]

#Append the room to the room list
room_list.append(room)
room = ["the Kitchen that has pots and pans setup for cooking.", None, 0, 2, None]
room_list.append(room)
room = ["the Dining room that has plates and silverwear set out.", 1, 3, None, None]
room_list.append(room)
room = ["the South hall that has many sets of different armor.", 0, 5, 6, 2]
room_list.append(room)
room = ["Bedroom 1 that has a bed, closet, and bathroom.", None, None, 5, 0]
room_list.append(room)
room = ["Bedroom 2 that also has a bed, closet, and bathroom.", 4, None, None, 3]
room_list.append(room)
room = ["the Balcony that oversees the lake behind the castle.", 3, None, None, None]
room_list.append(room)

#Make new variable called current_room set it to zero.
current_room = 0

#print the room_list variable run the program to test it.
#print(room_list)

#Use the current_room and room_list to print which room the user is in.

#Since your first room is zero, the output should be the same as before.
done = False
while not done:
print()
print("You are in", room_list [current_room][0])
answer = input("What do you want to do?: ")
if answer.lower()[0] == "n":
next_room = room_list[current_room][1]

elif answer.lower()[0] == "e":
next_room = room_list[current_room][2]

elif answer.lower()[0] == "s":
next_room = room_list[current_room][3]

elif answer.lower()[0] == "w":
next_room = room_list[current_room][4]

elif answer.lower()[0] == "q":
break

if next_room == None:
print("You can't go that way.")
else:
current_room = next_room

print("Have a nice day.")
Loading