From f8f46f73b20c944b84ab25433609bd725beda545 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Thu, 2 Nov 2017 07:59:36 -0500 Subject: [PATCH 01/15] labs completeddddd --- Lab 01 - Calculator/lab_01_part_a.py | 8 +++++++- Lab 01 - Calculator/lab_01_part_b.py | 10 +++++++++- Lab 01 - Calculator/lab_01_part_c.py | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Lab 01 - Calculator/lab_01_part_a.py b/Lab 01 - Calculator/lab_01_part_a.py index 792d600..e1480c4 100644 --- a/Lab 01 - Calculator/lab_01_part_a.py +++ b/Lab 01 - Calculator/lab_01_part_a.py @@ -1 +1,7 @@ -# +#!/usr/bin/env python3 +# Calculator part a +# Christian Groves +# 11-1-17 +Fahrenheit = int(input('Enter temperature in Fahrenheit: ')) +Celcius = ((Fahrenheit - 32) / 1.8) +print(str(Celcius)) \ No newline at end of file diff --git a/Lab 01 - Calculator/lab_01_part_b.py b/Lab 01 - Calculator/lab_01_part_b.py index 792d600..151e7a0 100644 --- a/Lab 01 - Calculator/lab_01_part_b.py +++ b/Lab 01 - Calculator/lab_01_part_b.py @@ -1 +1,9 @@ -# +#!/usr/bin/env python3 +# Calculator part a +# Christian Groves +# 11-1-17 +print('Area of a trapezoid') +height = int(input('Enter the height of the trapezoid: ')) +bottombase = int(input('Enter the length of the botom base: ')) +topbase = int(input('Enter the length of the top base: ')) +print('The area is: ' + str((1/2)*(bottombase + topbase) * height)) \ No newline at end of file diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index 792d600..f0702d1 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -1 +1,8 @@ -# +#!/usr/bin/env python3 +# Calculator part a +# Christian Groves +# 11-1-17 +import math +print('Area of a Pentagon') +sidelen = ('Enter side lenght') +print('Area of a pentagon is: ' + (5(5+2 5**()**(1/40)) \ No newline at end of file From 548f43d32901bd874dfcde0c743869ccd6b83101 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Thu, 2 Nov 2017 08:05:39 -0500 Subject: [PATCH 02/15] labs completed --- Lab 01 - Calculator/lab_01_part_c.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index f0702d1..23b3007 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -3,6 +3,7 @@ # Christian Groves # 11-1-17 import math -print('Area of a Pentagon') -sidelen = ('Enter side lenght') -print('Area of a pentagon is: ' + (5(5+2 5**()**(1/40)) \ No newline at end of file +print('Area of a Square') +sidelen = int(input('Enter side lenght: ')) +areasquare = sidelen ** 2 +print('Area of the Square is: ' + str(areasquare)) \ No newline at end of file From c4e0da39dc5a9422a0d20d3bcd2c06d046d6c587 Mon Sep 17 00:00:00 2001 From: Christian Groves <33127214+ChristianGroves@users.noreply.github.com> Date: Thu, 2 Nov 2017 09:05:38 -0500 Subject: [PATCH 03/15] Update worksheet_02.txt --- Worksheets/worksheet_02.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index abe4cd7..a334c2c 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -6,37 +6,38 @@ 1. Give an example of a binary number. (While a number such as ``1'' can be a binary, decimal, and hexadecimal number, try coming up with an example that better illustrates the differences between the different bases of numbers.) - +0010 2 2. Give an example of a decimal number. - +.6 3. Give an example of a hexadecimal number. - +a2 4. Convert the numbers 1, 10, 100, 1000, and 10000 from binary to decimal. - +1 2 4 8 16 5. What is a compiler? - +iIt changes our code to computer code 6. What is source code? - +Base code of a program in english 7. What is machine language? (Don't just say binary. That's not correct.) 8. What is a first generation language? (Don't just say binary. That's not correct.) 9. What is a second generation language? - +python2 10. What is a third generation language? (Explain, don't just give one example.) - +python3 it is the most up to date language that is faster and can do more complex +tasks than the last 11. What is an interpreter and how does it differ from a compiler? - +a interpeter translates from what we understand to what a computer can read 12. Search the web and find some of the most popular programming languages. List the website(s) you got the information from and what the languages are. - +c sharp c++ java python 13. Look at the job boards and see what languages people are looking for. List the languages and the job board you looked at. - +JAVA and C++ bureau of labor statistics 14. What is the difference between the ``syntax'' and ``semantics'' of a language? - +syntax is a structure error meaning assigned 15. Pick a piece of technology, other than a computer you use regularly. Briefly describe the hardware and software that run on it. - +calculator From 3a61aa51b0f52f20711b5db9fd261826813480ec Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Fri, 3 Nov 2017 09:18:30 -0500 Subject: [PATCH 04/15] answered sheets --- Worksheets/worksheet_03.txt | 87 ++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 30 deletions(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index bc85b84..7c55196 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -15,9 +15,21 @@ if it is positive, negative, or zero. Use a proper if/elif/else chain, don't just use three if statements. +innum = input('Enter a number: ') +if innum > 0: + print('Positive') +elif innum < 0 + print('Negative') +else: + print('Zero') + 3. Write a Python program that will take in a number from a user and print out ``Success'' if it is greater than -10 and less than 10, inclusive. (1 pt) - + +innum = input('Enter a number: ') +if innum >= -10 and innum <= 10 + print('Success') + 4. This runs, but there is something wrong. What is it? (1 pt) user_input = input("A cherry is a: ") @@ -27,24 +39,30 @@ print("Correct!") else: print("Incorrect.") - +it will always answer incorrect unless A is the input B has no specific +response + 5. There are two things wrong with this code that tests if x is set to a positive value. One prevents it from running, and the other is subtle. Make sure the if statement works no matter what x is set to. Identify both issues. (2 pts) - x == 4 - if x >= 0: + x = 4 + if x > 0: print("x is positive.") else: print("x is not positive.") - +less than or equal to is no longer a issue and x is now equal to 4 instead +of compared to 4 + 6. What three things are wrong with the following code? (3 pts) x = input("Enter a number: ") if x = 3 print("You entered 3") - +no int() on the input, it does not compare x to 3 but uses a invalid sign, +nothing happens unless 3 is input + 7. There are four things wrong with this code. Identify all four issues. (4 pts) answer = input("What is the name of Dr. Bunsen Honeydew's assistant? ") @@ -52,13 +70,16 @@ print("Correct!") else print("Incorrect! It is Beaker.") - +answer is not the same as "a", the indentions are messed up, else is missing a +colon, the if statment needs to be == so that it will compare them + 8. This program doesn't work correctly. What is wrong? (1 pt) x = input("How are you today?") if x == "Happy" or "Glad": print("That is good to hear!") - +it will always print('that is good to hear!') + 9. Look at the code below. Write you best guess here on what it will print. Next, run the code and see if you are correct. Clearly label your guess and the actual answer. @@ -78,37 +99,43 @@ print("Fizz") if z: print("Buzz") - +buzz +Output: +x= 5 +y= False +z= True +Buzz + 10. Look at the code below. Write you best guess on what it will print. Next, run the code and see if you are correct. (2 pts) x = 5 y = 10 z = 10 - print(x < y) - print(y < z) - print(x == 5) - print(not x == 5) - print(x != 5) - print(not x != 5) - print(x == "5") - print(5 == x + 0.00000000001) - print(x == 5 and y == 10) - print(x == 5 and y == 5) - print(x == 5 or y == 5) + print(x < y) true + print(y < z) false + print(x == 5) true + print(not x == 5) invalid + print(x != 5) false + print(not x != 5) invalid + print(x == "5") invalid + print(5 == x + 0.00000000001) false + print(x == 5 and y == 10) true true + print(x == 5 and y == 5) true false + print(x == 5 or y == 5) true false 11. Look at the code below. Write you best guess on what it will print. Next, run the code and see if you are correct. (2 pts) - print("3" == "3") - print(" 3" == "3") - print(3 < 4) - print(3 < 10) - print("3" < "4") - print("3" < "10") - print( (2 == 2) == "True" ) - print( (2 == 2) == True ) - print(3 < "3") + print("3" == "3") true + print(" 3" == "3") false + print(3 < 4) true + print(3 < 10) true + print("3" < "4") true + print("3" < "10") false + print( (2 == 2) == "True" ) false + print( (2 == 2) == True ) true + print(3 < "3") invalid 12. What things are wrong with this section of code? @@ -131,5 +158,5 @@ money = 50 - +it should be elif for ocupation b and c and there should be a else statment asking again if a invalid input is input. From 5ace6ae1c59d8e435b1ede31b8470329450fa4ae Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Mon, 6 Nov 2017 08:25:36 -0600 Subject: [PATCH 05/15] Completed Lab for section 3 --- Lab 03 - Create a Quiz/main_program.py | 50 +++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index 792d600..8546345 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -1 +1,49 @@ -# +#!/user/bin/env python3 +#Create a Quiz +#Christian Groves +#11-3-17 +counter = 0 +print('Pop Quiz') +answer1 = input('''What is the largest free to play game on PC: ''') +if answer1.lower() == 'warframe': + print('Correct') + counter += 1 +else: + print('Incorrect') + +answer2 = input('''When comes after 20013: ''') +if answer2 == '20014': + print('Correct') + counter += 1 +else: + print('Incorrect') + +answer3 = input('''What is the powerhouse of the cell: ''') +if answer3.lower() == 'mitochondria': + print('Correct') + counter += 1 +else: + print('Incorrect') + +answer4 = input('''What is the answer to the universe: ''') +if answer4 == '42': + print('Correct') + counter += 1 +else: + print('Incorrect') + +print('A. You') +print('B. Bill Gates') +print('C. Rick and Morty') +answer5 = input('''Who is dead: ''') + +if answer5.lower() == 'b': + print('Correct') + counter += 1 +else: + print('Incorrect') +if counter >= 4: + print("Congrats, you didn't fail") + print('Your score is ' + str(counter * 20) +'.0 percent.') +else: + print('Your score was terrible only a ' + str(counter * 20) + '.0 percent.') \ No newline at end of file From e5762c762a32d86ba3d3ad6d03fb2835c38b0c92 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Thu, 9 Nov 2017 18:45:21 -0600 Subject: [PATCH 06/15] Camel --- Lab 04 - Camel/main_program.py | 84 +++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 792d600..aed0074 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1 +1,83 @@ -# +#!/usr/bin/env python3 +#Camel +#Christian Groves +#11/9/17 +import random +print('Welcome to Camel!') +print('You have stolen a camel to make your way across the great Mobi desert.') +print('The natives want their camel back and are chasing you down! Survive your') +print('desert trek and out run the natives.') +done = False +oasis = 0 +miles = 0 +thirst = 0 +cameltired = 0 +nativestravel = -20 +cantinedrinks = 3 +alive = True +while done is False: + print('A. Drink from your canteen.') + print('B. Ahead moderate speed.') + print('C. Ahead full speed.') + print('D. Stop for the night.') + print('E. Status check.') + print('Q. Quit.') + userchoice = input('Your choice? ') + oasis = random.randrange(0, 20) + if userchoice.upper() == 'Q': + done = True + elif userchoice.upper() == 'D': + cameltired = 0 + print('Your camel is happy.') + nativestravel += random.randrange(7, 14) + elif userchoice.upper() == 'E': + print('Miles traveled: '+ str(miles)) + print('Drinks in canteen: ' + str(cantinedrinks)) + print('The natives are '+ str(nativestravel) + ' miles behind you.') + elif userchoice.upper() == 'C': + randomint = random.randrange(10, 20) + miles += randomint + print('Miles traveled ' + str(randomint)) + nativestravel += random.randrange(7, 14) + cameltired += random.randrange(1, 3) + thirst += 1 + elif userchoice.upper() == 'B': + randomint = random.randrange(5, 12) + miles += randomint + print('Miles traveled ' + str(randomint)) + nativestravel += random.randrange(7, 14) + cameltired += 1 + thirst += 1 + elif userchoice.upper() == 'A': + if cantinedrinks > 0: + cantinedrinks -= 1 + thirst = 0 + else: + print('Error') + if thirst > 4 and not thirst > 7 and done != True: + print('You are thirsty.') + elif thirst > 6 and done != True: + print('You died of thirst!') + done = True + alive = False + if cameltired > 5 and not cameltired > 9 and done != True: + print('Your camel is getting tired') + elif cameltired > 8 and done != True: + print('Your camel is dead.') + done = True + alive = False + if nativestravel > miles and done != True: + print('They have caught you') + alive = False + elif (nativestravel + 15) > miles and not nativestravel > miles: + print('The natives are getting close') + if oasis == 2: + print('You have found a oasis') + cantinedrinks = 3 + cameltired = 0 + thirst = 0 + if miles >= 200: + if done != True: + print('You win') + done = True + \ No newline at end of file From 96c90397daf826ca33e41e0bc7328fc6b7326ae2 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Tue, 14 Nov 2017 10:12:07 -0600 Subject: [PATCH 07/15] started ws6 1-5 completed --- Worksheets/worksheet_06.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 35e5f13..fab49bb 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -17,6 +17,8 @@ while x < 10: print(x) x = x + 2 + guess print 0 2 4 6 8 all on new lines + actually prints 0 2 4 6 8 all on new lines 2. What does this program print out? @@ -24,6 +26,8 @@ while x < 64: print(x) x = x * 2 + guess print 1 2 4 8 16 32 all on new lines + actual print 1 2 4 8 16 32 all on new lines 3. Why is the and x >= 0 not needed? @@ -31,6 +35,7 @@ while x < 10 and x >= 0: print(x) x = x + 2 + x starts at 0 and never goes down so its always true 4. What does this program print out? (0 pts) Explain. (1 pt) @@ -40,6 +45,7 @@ if x == "1": print("Blast off!") x = x - 1 + guess 5, 4, 3, 2, 1, 0 no blast off because str 1 != int 1 5. Fix the following code so it doesn't repeat forever, and keeps asking the user until he or she enters a number greater than zero: (2 pts) @@ -48,7 +54,7 @@ while x <= 0: print("Too small. Enter a number greater than zero: ") - + x = float(input("Enter a number greater than zero: ")) 6. Fix the following code: x = 10 From 0b853367b773b11f6128482436a8e51d47186ed9 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Wed, 15 Nov 2017 07:53:03 -0600 Subject: [PATCH 08/15] Completed ws6 --- Worksheets/worksheet_06.txt | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index fab49bb..dc9b101 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -59,25 +59,24 @@ x = 10 - while x < 0: + while x > 0: print(x) - x - 1 + x -= 1 print("Blast-off") 7. What is wrong with this code? It runs but it has unnecessary code. Find all the unneeded code. Also, answer why it is not needed. (1 pt) - i = 0 for i in range(10): print(i) i += 1 - + You do not need to set i to a number because it will be made in the for loop 8. Explain why the values printed for x are so different. (2 pts) # Sample 1 x = 0 - for i in range(10): + for i in range(10): each of these loops are only being ran once for a total of 20 runs in all x += 1 for j in range(10): x += 1 @@ -87,7 +86,7 @@ x = 0 for i in range(10): x += 1 - for j in range(10): + for j in range(10): this for loop is being done 10 times making it a total of 100 runs combined with the first it totals to 110 runs x += 1 print(x) From c56bf5ff6b03958997905aed8f7022debb50f07f Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Wed, 15 Nov 2017 08:07:53 -0600 Subject: [PATCH 09/15] Completed part1 of lab6 --- Lab 06 - Loopy Lab/part_1.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 8b13789..cf5ffac 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1 +1,12 @@ +#!/usr/bin/env python3 +#Lab #6 +#Christian Groves +#11-15-17 +#for loop to add +num = 10 +for row in range(1,10): + for col in range(row,0,-1): + print(num,end=' ') + num += 1 + print() \ No newline at end of file From 588423c701bcff6f27bd26c05aa9661134e33c97 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Wed, 15 Nov 2017 08:46:37 -0600 Subject: [PATCH 10/15] Completed part2 of lab6 --- Lab 06 - Loopy Lab/part_1.py | 2 +- Lab 06 - Loopy Lab/part_2.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index cf5ffac..ea96405 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -9,4 +9,4 @@ for col in range(row,0,-1): print(num,end=' ') num += 1 - print() \ No newline at end of file + print() diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 792d600..39f93e9 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1 +1,20 @@ -# +#!/usr/bin/env python3 +#Lab #6 +#Christian Groves +#11-15-17 + +#input for desired size +boxsize = int(input('Desired size: ')) +horizontal = boxsize*2 +spaces = (boxsize*2) -3 +verticle = boxsize-1 + +#for loop to add the rows of o's +for row in range(1): + print('o'*horizontal) +#for loop to add the col +for col in range(1,verticle): + print('o',' '*spaces,end='o\n') +#for loop to add the rows at the end with o's +for row in range(1): + print('o'*horizontal) From db1d133e56259eb145d76a3cc85773f9c4583ac1 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Thu, 16 Nov 2017 10:08:03 -0600 Subject: [PATCH 11/15] completed ch5 ws and started lab by creating the outline and grass for a canvas --- Lab 05 - Create a Picture/main_program.py | 36 ++++++++++++++++- Lab 06 - Loopy Lab/part_3.py | 24 +++++++++++- Worksheets/worksheet_05.txt | 48 ++++++++++++----------- 3 files changed, 84 insertions(+), 24 deletions(-) diff --git a/Lab 05 - Create a Picture/main_program.py b/Lab 05 - Create a Picture/main_program.py index 792d600..09314b1 100644 --- a/Lab 05 - Create a Picture/main_program.py +++ b/Lab 05 - Create a Picture/main_program.py @@ -1 +1,35 @@ -# +#!/usr/bin/env python3 +#Lab #5 +#Christian Groves +#11/16/17 +import pygame +pygame.init() +BLACK =(0,0,0) +WHITE =(255,255,255) +GREEN =(0,255,0) +RED =(255,0,0) +BLUE =(0,0,255) +size=(700,500) +screen = pygame.display.set_mode(size) +pygame.display.set_caption("Christian's Cool Game") +done = False +clock = pygame.time.Clock() +font = pygame.font.Font(None, 25) +while done == False: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + done=True + + + screen.fill(BLUE) + + pygame.draw.line(screen, GREEN , [0,400], [700,400],200) + pygame.draw.ellipse(screen, WHITE, [20, 20, 250, 100], 50) + + + + pygame.display.flip() + + clock.tick(20) + +pygame.quit () \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_3.py b/Lab 06 - Loopy Lab/part_3.py index 792d600..c6f170d 100644 --- a/Lab 06 - Loopy Lab/part_3.py +++ b/Lab 06 - Loopy Lab/part_3.py @@ -1 +1,23 @@ -# +#!/usr/bin/env python3 +#Lab #6 +#Christian Groves +#11-15-17 +size = int(input('Size: ')) + + +for row in range(1,10): + for digit1 in range(9 - row): + print(digit1, end=' ') + for spaces in range(1,row +1): + print(' ',end=' ') + for digit2 in range(row,0,-1): + print(digit2,end=' ') + print() +for botrow in range (9,0,-1): + for spacesbot in range(9- botrow, 0, -1): + print(' ',end=' ') + for digit3 in range(1, botrow+1): + print(digit3,end=' ') + for digit4 in range(botrow,0,-1): + print(digit4,end=' ') + print() \ No newline at end of file diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index 275a18a..367a73f 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -7,63 +7,67 @@ 1. Explain how the computer coordinate system differs from the standard Cartesian coordinate system. There are two main differences. List both. - +the top left coordinates are 0,0 and the x increases normaly where as the y increases as it goes down 2. Before a Python Pygame program can use any functions like pygame.display.set_mode(), what two lines of code must occur first? - +import pygame +pygame.init() 3. Explain how WHITE = (255, 255, 255) represents a color. - +it shows all of the colors in a RGB spectrum first number being red second green and third blue when combined in full intesity\ +they are white 4. When do we use variable names for colors in all upper-case, and when do we use variable names for colors in all lower-case? (This applies to all variables, not just colors.) 5. What does the pygame.display.set_mode() function do? - +it is used to set the size 6. What does this for event in pygame.event.get() loop do? - +it checks each time a event happens and then executes everything in its loop 7. What is pygame.time.Clock used for? - +it is used to set the refreshrate 8. For this line of code: (3 pts) pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 5) - * What does screen do? - * What does [0, 0] do? - * What does [100, 100] do? - * What does 5 do? + * What does screen do? it tells where to draw this line + * What does [0, 0] do? it tells the first x,y cord + * What does [100, 100] do? it tells the second x,y cord + * What does 5 do? it tells the width of the line 9. What is the best way to repeat something over and over in a drawing? - +loop it in a while loop 10. When drawing a rectangle, what happens if the specified line width is zero? - +nothing shows up 11. Describe the ellipse drawn in the code below. - * What is the x, y of the origin coordinate? - * What does the origin coordinate specify? The center of the circle? - * What is the length and the width of the ellipse? + * What is the x, y of the origin coordinate? [20, 20] + * What does the origin coordinate specify? The center of the circle? it starts at the upper right corner of the elipse that not the center + * What is the length and the width of the ellipse? 230w x 80h pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2) 12. When drawing an arc, what additional information is needed over drawing an ellipse? - +the radians are needed in order to determine the arc direction 13. Describe, in general, what are the three steps needed when printing text to the screen using graphics? - +you need the font, text with the color and size and finally you need to print it to the screen with blit 14. When drawing text, the first line of the three lines needed to draw text should actually be outside the main program loop. It should only run once at the start of the program. Why is this? You may need to ask. - +You don't need to keep defining the same thing 20 times a second when it only needs to be set once 15. What are the coordinates of the polygon that the code below draws? pygame.draw.polygon(screen, BLACK, [[50,100],[0,200],[200,200],[100,50]], 5) - +The cords are [50,100],[0,200],[200,200],[100,50] 16. What does pygame.display.flip() do? - +it displays all items drawn on the creen 17. What does pygame.quit() do? - +it closes the program 18. Look up on-line how the pygame.draw.circle works. Get it working and paste a working sample here. I only need the one line of code that draws the circle, but make sure it is working by trying it out in a full working program. - + +it takes the surface, color, position, radius, and width +pygame.draw.circle(screen, BLACK, [50,50], 20, 1) From a1e68f91711dfc353376576faa330fc5b1b557d4 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Fri, 17 Nov 2017 08:05:14 -0600 Subject: [PATCH 12/15] added some clouds --- Lab 05 - Create a Picture/main_program.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Lab 05 - Create a Picture/main_program.py b/Lab 05 - Create a Picture/main_program.py index 09314b1..12896fa 100644 --- a/Lab 05 - Create a Picture/main_program.py +++ b/Lab 05 - Create a Picture/main_program.py @@ -9,6 +9,7 @@ GREEN =(0,255,0) RED =(255,0,0) BLUE =(0,0,255) +PURPLE =(150,20,130) size=(700,500) screen = pygame.display.set_mode(size) pygame.display.set_caption("Christian's Cool Game") @@ -22,9 +23,21 @@ screen.fill(BLUE) + #green ground + pygame.draw.line(screen, GREEN , [0,400], [700,400],200) + #first cloud + pygame.draw.ellipse(screen, WHITE, [40, 20, 130, 90]) + pygame.draw.ellipse(screen, WHITE, [70, 30, 140, 110]) + pygame.draw.ellipse(screen, WHITE, [20, 40, 140, 110]) + #second cloud + pygame.draw.ellipse(screen, WHITE, [440, 50, 140, 110]) + pygame.draw.ellipse(screen, WHITE, [460, 20, 140, 110]) + pygame.draw.ellipse(screen, WHITE, [480, 60, 140, 110]) + #House + pygame.draw.rect(screen, PURPLE, [300, 320, 300, 320]) + + - pygame.draw.line(screen, GREEN , [0,400], [700,400],200) - pygame.draw.ellipse(screen, WHITE, [20, 20, 250, 100], 50) From 970a34468b9d8021c69c1ba8ba48d86f4beb5147 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Tue, 28 Nov 2017 07:28:40 -0600 Subject: [PATCH 13/15] finished: Lab 05 - Create a Picture/main_program.py finished: Lab 06 - Loopy Lab/part_4.py modified: Lab 07 - Adventure/main_program.py --- Lab 05 - Create a Picture/main_program.py | 28 +++++++----- Lab 06 - Loopy Lab/part_4.py | 56 ++++++++++++++++++++++- Lab 07 - Adventure/main_program.py | 47 ++++++++++++++++++- 3 files changed, 117 insertions(+), 14 deletions(-) diff --git a/Lab 05 - Create a Picture/main_program.py b/Lab 05 - Create a Picture/main_program.py index 12896fa..b7994d0 100644 --- a/Lab 05 - Create a Picture/main_program.py +++ b/Lab 05 - Create a Picture/main_program.py @@ -4,6 +4,10 @@ #11/16/17 import pygame pygame.init() +greenColor = 175 +radius = 180 +sunChange= (200,greenColor,40) +LIGHTBLUE=(126,213,242) BLACK =(0,0,0) WHITE =(255,255,255) GREEN =(0,255,0) @@ -11,17 +15,13 @@ BLUE =(0,0,255) PURPLE =(150,20,130) size=(700,500) +xoff= 700 screen = pygame.display.set_mode(size) pygame.display.set_caption("Christian's Cool Game") done = False clock = pygame.time.Clock() font = pygame.font.Font(None, 25) while done == False: - for event in pygame.event.get(): - if event.type == pygame.QUIT: - done=True - - screen.fill(BLUE) #green ground pygame.draw.line(screen, GREEN , [0,400], [700,400],200) @@ -32,13 +32,17 @@ #second cloud pygame.draw.ellipse(screen, WHITE, [440, 50, 140, 110]) pygame.draw.ellipse(screen, WHITE, [460, 20, 140, 110]) - pygame.draw.ellipse(screen, WHITE, [480, 60, 140, 110]) - #House - pygame.draw.rect(screen, PURPLE, [300, 320, 300, 320]) - - - - + pygame.draw.ellipse(screen, WHITE, [480, 60, 140, 110]) + for event in pygame.event.get(): + if event.type == pygame.QUIT: + done=True + + #House's + for xoff in range(700, 0, -200): + pygame.draw.rect(screen, PURPLE, [50+ xoff , 260, 100, 110]) + pygame.draw.rect(screen, BLACK, [70+ xoff , 300, 30, 70]) + pygame.draw.rect(screen, WHITE, [110+ xoff , 300, 30, 30]) + pygame.draw.polygon(screen, RED, [[25+ xoff , 260], [175+ xoff, 260], [100+ xoff , 200]]) pygame.display.flip() diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 792d600..a6b7942 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -1 +1,55 @@ -# +#!/usr/bin/env python3 +#Lab 6 part 4 +#Christian Groves +#11/21/17 +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 = (700, 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(BLACK) + for x in range(0,700, 5): + for y in range + # --- Drawing code should go here + + # --- 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() \ No newline at end of file diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 792d600..7a5153f 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1 +1,46 @@ -# +#!/usr/bin/env python3 +#Lab 6 +#Christian Groves +#11/20/17 +roomList = [] +#CMN +room = ['You are in Computer Maintinance Networking. \nCentral hallway to the North.', 3, None, None, None] +roomList.append(room) +#CSD +room = ['You are in Computer Software Development. \nEast hallway to the North.', 4, None, None, None] +roomList.append(room) +#HALL0 +room = ['You are in the West Hallway. \nBathroom is to the North. Central hallway is to the East.', 5, 3, None, None] +roomList.append(room) +#HALL1 +room = ['You are in the Central Hallway. \nWelding is to the North. East hallway is to the East. \nCMN is to the South. West hallway is to the West.', 6, 4, 0, 2] +roomList.append(room) +#HALL2 +room = ['You are in the East Hallway. \nAuto Collision is to the North. CSD is to the South. \nCentral hallway is to the West.', 7, None, 1, 3] +roomList.append(room) +#BATHROOM +room = ['You are in the Bathroom. \nWest hallway is to the south.', None, None, 2, None] +roomList.append(room) +#WELDING +room = ['You are in Welding. \nCentral hallway is to the south.', None, None,6, None] +roomList.append(room) +#AUTO +room = ['You are in Auto Collision. \nEast hallway is to the south.', None, None, 4, None] +roomList.append(room) + +nextRoom = 0 +currentRoom = 0 +done = False +while done == False: + print() + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') + if dirChoice == 'North': + if [currentRoom][1] == 2: + nextRoom = roomList[currentRoom][1] + elif [currentRoom][1] == None: + print("You can't go that way. ") + else: + currentRoom = nextRoom + + \ No newline at end of file From 81c679c510151e6583e3af5ac0dbc621972290f2 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Tue, 28 Nov 2017 08:39:09 -0600 Subject: [PATCH 14/15] Finished Chapter 6 part 4 and added movment to Chapter 7 lab --- Lab 06 - Loopy Lab/part_4.py | 3 +- Lab 07 - Adventure/main_program.py | 55 +++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index a6b7942..45eaa43 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -42,7 +42,8 @@ # background image. screen.fill(BLACK) for x in range(0,700, 5): - for y in range + for y in range(0,500,5): + pygame.draw.rect(screen, GREEN, [1 + x,1 + y ,2,2]) # --- Drawing code should go here # --- Go ahead and update the screen with what we've drawn. diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 7a5153f..22042ff 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -22,7 +22,7 @@ room = ['You are in the Bathroom. \nWest hallway is to the south.', None, None, 2, None] roomList.append(room) #WELDING -room = ['You are in Welding. \nCentral hallway is to the south.', None, None,6, None] +room = ['You are in Welding. \nCentral hallway is to the south.', None, None, 3, None] roomList.append(room) #AUTO room = ['You are in Auto Collision. \nEast hallway is to the south.', None, None, 4, None] @@ -30,17 +30,56 @@ nextRoom = 0 currentRoom = 0 + done = False while done == False: print() print(roomList[currentRoom][0]) dirChoice = input('What direction do you want to go? ') + + #dirChoice direction if dirChoice == 'North': - if [currentRoom][1] == 2: - nextRoom = roomList[currentRoom][1] - elif [currentRoom][1] == None: - print("You can't go that way. ") + dirChoice = 0 + elif dirChoice == 'South': + dirChoice = 1 + elif dirChoice == 'West': + dirChoice = 2 + elif dirChoice == 'East': + dirChoice = 3 + else: + print("\nYou can't go that way! ") + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') + + #North + if dirChoice == 0: + if (roomList[currentRoom][1]) == None: + print("\nYou can't go that way! ") + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') + else: + currentRoom = (roomList[currentRoom][1]) + #South + if dirChoice == 1: + if (roomList[currentRoom][3]) == None: + print("\nYou can't go that way! ") + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') + else: + currentRoom = (roomList[currentRoom][3]) + #West + if dirChoice == 2: + if (roomList[currentRoom][4]) == None: + print("\nYou can't go that way! ") + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') + else: + currentRoom = (roomList[currentRoom][4]) + #East + if dirChoice == 3: + if (roomList[currentRoom][2]) == None: + print("\nYou can't go that way! ") + print(roomList[currentRoom][0]) + dirChoice = input('What direction do you want to go? ') else: - currentRoom = nextRoom - - \ No newline at end of file + currentRoom = (roomList[currentRoom][2]) \ No newline at end of file From 3b3e4a1fa73184c14314c08c0423ec3bf2f6b165 Mon Sep 17 00:00:00 2001 From: ChristianGroves Date: Wed, 29 Nov 2017 10:05:05 -0600 Subject: [PATCH 15/15] Finished lab 7 --- Lab 07 - Adventure/main_program.py | 68 ++++++++++++++++++------------ 1 file changed, 42 insertions(+), 26 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 22042ff..d4509b0 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1,31 +1,34 @@ #!/usr/bin/env python3 -#Lab 6 +#Lab 6 Maze Game #Christian Groves #11/20/17 + +'''Maze adventure''' + roomList = [] #CMN -room = ['You are in Computer Maintinance Networking. \nCentral hallway to the North.', 3, None, None, None] +room = ['You are in Computer Maintinance Networking.', 3, None, None, None] roomList.append(room) #CSD -room = ['You are in Computer Software Development. \nEast hallway to the North.', 4, None, None, None] +room = ['You are in Computer Software Development.', 4, None, None, None] roomList.append(room) #HALL0 -room = ['You are in the West Hallway. \nBathroom is to the North. Central hallway is to the East.', 5, 3, None, None] +room = ['You are in the West Hallway.', 5, 3, None, None] roomList.append(room) #HALL1 -room = ['You are in the Central Hallway. \nWelding is to the North. East hallway is to the East. \nCMN is to the South. West hallway is to the West.', 6, 4, 0, 2] +room = ['You are in the Central Hallway.', 6, 4, 0, 2] roomList.append(room) #HALL2 -room = ['You are in the East Hallway. \nAuto Collision is to the North. CSD is to the South. \nCentral hallway is to the West.', 7, None, 1, 3] +room = ['You are in the East Hallway.', 7, None, 1, 3] roomList.append(room) #BATHROOM -room = ['You are in the Bathroom. \nWest hallway is to the south.', None, None, 2, None] +room = ['You are in the Bathroom.', None, None, 2, None] roomList.append(room) #WELDING -room = ['You are in Welding. \nCentral hallway is to the south.', None, None, 3, None] +room = ['You are in Welding.', None, None, 3, None] roomList.append(room) #AUTO -room = ['You are in Auto Collision. \nEast hallway is to the south.', None, None, 4, None] +room = ['You are in Auto Collision.', None, None, 4, None] roomList.append(room) nextRoom = 0 @@ -33,53 +36,66 @@ done = False while done == False: + posibleRooms = [] print() print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + if (roomList[currentRoom][1]) != None: + posibleRooms.append('North ') + if (roomList[currentRoom][2]) != None: + posibleRooms.append('East ') + if (roomList[currentRoom][3]) != None: + posibleRooms.append('South ') + if (roomList[currentRoom][4]) != None: + posibleRooms.append('West ') + + print('You can go ',end = '') + for i in range(len(posibleRooms)): + print(str(posibleRooms[i]),end= ' ') + dirChoice = input('\nWhat direction do you want to go? ') #dirChoice direction - if dirChoice == 'North': + if dirChoice.upper()[0] == 'N': dirChoice = 0 - elif dirChoice == 'South': + elif dirChoice.upper()[0] == 'S': dirChoice = 1 - elif dirChoice == 'West': + elif dirChoice.upper()[0] == 'W': dirChoice = 2 - elif dirChoice == 'East': + elif dirChoice.upper()[0] == 'E': dirChoice = 3 - else: - print("\nYou can't go that way! ") - print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + elif dirChoice == 'cry': + print("\nCrying won't do anything for you! ") + continue + elif dirChoice.upper()[0] == 'Q': + break #North if dirChoice == 0: if (roomList[currentRoom][1]) == None: print("\nYou can't go that way! ") - print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + continue else: currentRoom = (roomList[currentRoom][1]) + #South if dirChoice == 1: if (roomList[currentRoom][3]) == None: print("\nYou can't go that way! ") - print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + continue else: currentRoom = (roomList[currentRoom][3]) + #West if dirChoice == 2: if (roomList[currentRoom][4]) == None: print("\nYou can't go that way! ") - print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + continue else: currentRoom = (roomList[currentRoom][4]) + #East if dirChoice == 3: if (roomList[currentRoom][2]) == None: print("\nYou can't go that way! ") - print(roomList[currentRoom][0]) - dirChoice = input('What direction do you want to go? ') + continue else: currentRoom = (roomList[currentRoom][2]) \ No newline at end of file