From 865443fbe5a1aa204562090509edb9127b7912a9 Mon Sep 17 00:00:00 2001 From: Jake Faucett Date: Mon, 6 Nov 2017 13:29:42 -0600 Subject: [PATCH 1/5] Put in answers --- Worksheets/worksheet_01.txt | 49 +++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/Worksheets/worksheet_01.txt b/Worksheets/worksheet_01.txt index 728ad02..99ee1b0 100644 --- a/Worksheets/worksheet_01.txt +++ b/Worksheets/worksheet_01.txt @@ -6,25 +6,23 @@ and punctuation. Please limit the length of each line to 80 characters. 1. Write a line of code that will print your name. - - 2. How do you enter a comment in a program? - +print('Jake Faucett') + 2. How do you enter a comment in a program? # 3. What do the following lines of code output? ALSO: Why do they give a different answer? - + Answer:(2 / 3) = 0.66 (2 // 3)= 0 print(2 / 3) print(2 // 3) - - 4. Write a line of code that creates a variable called pi and sets - it to an appropriate value. - + The reason they are different is because floor division rounds it while regular division doesn't + 4. Write a line of code that creates a variable called pi and sets it to an appropriate value. +pi = 3 5. Why does this code not work? - + It wouldn't work because the first a is capitalized A = 22 print(a) 6. All of the variable names below can be used. But which ONE of these is - the better variable name to use? + the better variable name to use? area_of_rectangle a A @@ -60,18 +58,19 @@ x2x total% #left - + Answer: account number because you cannot have spaces 8. Why does this code not work? print(a) a = 45 + Answer: Because the print statement needs to be after the variable got set to a value. 9. Explain the mistake in this code: pi = float(3.14) - 10. This program runs, but the code still could be better. Explain what is - wrong with the code. + Answer: the 3.14 is unnecessary since it already is a float. + 10. This program runs, but the code still could be better. Explain what is wrong with the code. radius = float(input("Radius:")) x = 3.14 @@ -79,6 +78,7 @@ area = pi * radius ** 2 print(area) + Answer: you could get rid of the variable x entirely. 11. Explain the mistake in the following code: x = 4 @@ -86,6 +86,7 @@ a = ((x) * (y)) print(a) + Answer: There is multiple statements found while compiling a single statement. 12. Explain the mistake in the following code: x = 4 @@ -93,53 +94,63 @@ a = 3(x + y) print(a) + Answer: There is multiple statements found while compiling a single statement. 13. Explain the mistake in the following code: radius = input(float("Enter the radius:")) + Answer: They called for radius to be printed 14. Do all these print the same value? Which one is better to use and why? print(2/3+4) print(2 / 3 + 4) print( 2 / 3+ 4 ) + Answer: Yes they print the same value. The second one is the best because you don't want too many spaces but you do want some so it is not so clustered. 15. What is a constant? - +A variable that stays the same. 16. How are variable names for constants different than other variable names? + Answer: A constant stays the same but a constant will be able to change. 17. What is a single quote and what is a double quote? Give and label an example of both. - + 'My name' + + "My name" 18. Write a Python program that will use escape codes to print a double-quote and a new line using the Window's standard. (Note: I'm asking for the Window's standard here. Look it up out of Chapter 1.) + Answer: print('""'/n) 19. Can a Python program print text to the screen using single quotes instead of double quotes? + Answer: Yes 20. Why does this code not calculate the average? print(3 + 4 + 5 / 3) - +Answer: It does division first because of order of operations 21. What is an ``operator'' in Python? + Answer:An operator is a character that represents an action, 22. What does the following program print out? x = 3 x + 1 print(x) - +Answer: 3 23. Correct the following code: user_name = input("Enter your name: )" - + + + Answer:username =input('Enter you name: ') + + print(username) 24. Correct the following code: value = int(input(print("Enter your age"))) - +Answer:int(input("Enter your age: ")) From 19dd9ae06b520351dac36f9b293025e464f362b7 Mon Sep 17 00:00:00 2001 From: Jake Faucett Date: Tue, 7 Nov 2017 12:58:19 -0600 Subject: [PATCH 2/5] Finished labs --- Lab 01 - Calculator/lab_01_part_a.py | 18 ++++++++++++++++++ Lab 01 - Calculator/lab_01_part_b.py | 16 ++++++++++++++++ Lab 01 - Calculator/lab_01_part_c.py | 14 ++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/Lab 01 - Calculator/lab_01_part_a.py b/Lab 01 - Calculator/lab_01_part_a.py index 792d600..90c0330 100644 --- a/Lab 01 - Calculator/lab_01_part_a.py +++ b/Lab 01 - Calculator/lab_01_part_a.py @@ -1 +1,19 @@ # +#!/usr/bin/env.python3 +#Converting Fahrenheit to Celsius +#Jake Faucett +#11-7-17 + + + + + +tempF = int(input('Enter temperature in Fahrenheit: ')) + +#Converting Fahrenhiet to Celcuis + +tempC = (tempF - 32) * (5/9) + +#Print this to the console + +print('The temperature in Celcuis: ', tempC) \ 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..86357db 100644 --- a/Lab 01 - Calculator/lab_01_part_b.py +++ b/Lab 01 - Calculator/lab_01_part_b.py @@ -1 +1,17 @@ # + +#!/usr/bin/env.python3 +#Converting Fahrenheit to Celsius +#Jake Faucett +#11-7-17 + +#Find the Area of a Trapezoid + +height = int(input('Enter the height of the trapezoid: ')) +lengthB = int(input('Enter the length of the bottom base: ')) +lengthT = int(input('Enter the length of the top base: ')) + +#Calculate the area +Area = 0.5 * (lengthB + lengthT) * height + +print ('The area is: ', Area) diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index 792d600..6ea3165 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -1 +1,15 @@ # +#!/usr/bin/env.python3 +#Converting Fahrenheit to Celsius +#Jake Faucett +#11-7-17 + +#Solving the area of a circle + +r = int(input('Enter the radius of the circle: ')) + +#Calculate the Area + +Area =int(3.14 * r ** 2) + +print('The area of the circle: ', Area) \ No newline at end of file From 483ca763d6fe744435d129eecb2021659165e73d Mon Sep 17 00:00:00 2001 From: jfaucett31 <33132722+jfaucett31@users.noreply.github.com> Date: Thu, 9 Nov 2017 13:39:34 -0600 Subject: [PATCH 3/5] Update worksheet_02.txt --- Worksheets/worksheet_02.txt | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index abe4cd7..8f0e965 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -6,37 +6,37 @@ 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.) - +Answer:100101 2. Give an example of a decimal number. - +Answer:0.238 3. Give an example of a hexadecimal number. - +Answer:A37E 4. Convert the numbers 1, 10, 100, 1000, and 10000 from binary to decimal. - +Answer:1, 2, 4, 8, 16 5. What is a compiler? - +Answer: A special program that processes statements written in a particular programming language and turns them into machine language 6. What is source code? - +Answer: a text listing of commands to be compiled or assembled into an executable computer program. 7. What is machine language? (Don't just say binary. That's not correct.) - +Answer:The coding 8. What is a first generation language? (Don't just say binary. That's not correct.) - +Answer: the level of instructions and data that the processor is actually given to work on 9. What is a second generation language? - +Answer:An assembler converts the assembler language statements into machine language. 10. What is a third generation language? (Explain, don't just give one example.) - +Answer:It's a complete program code 11. What is an interpreter and how does it differ from a compiler? - +Answer:a program that can analyze and execute a program line by line. 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. - +Answer:Java, Python, C https://www.inc.com/larry-kim/10-most-popular-programming-languages-today.html 13. Look at the job boards and see what languages people are looking for. List the languages and the job board you looked at. - +Answer:Java 14. What is the difference between the ``syntax'' and ``semantics'' of a - language? - + language? Syntax is a word error while semantics is invloving symbols +Answer: 15. Pick a piece of technology, other than a computer you use regularly. Briefly describe the hardware and software that run on it. - +Answer:Samsung S7 edge phone, Android 6.0.1 Marshmallow From 412e7cc48435b1eb49b918c039e40aa4b06c9de8 Mon Sep 17 00:00:00 2001 From: Jake Faucett Date: Wed, 15 Nov 2017 12:07:18 -0600 Subject: [PATCH 4/5] worksheet done Please enter the commit message for your changes. Lines starting --- Lab 06 - Loopy Lab/chap6.py | 11 +++++++++++ Worksheets/worksheet_06.txt | 15 +++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 Lab 06 - Loopy Lab/chap6.py diff --git a/Lab 06 - Loopy Lab/chap6.py b/Lab 06 - Loopy Lab/chap6.py new file mode 100644 index 0000000..1b0a63f --- /dev/null +++ b/Lab 06 - Loopy Lab/chap6.py @@ -0,0 +1,11 @@ +#!/user/bin/env python3 +#chap6.py +#Jake Faucett +#11/13/17 + +x = 0 +for i in range(10): + x += 1 + for j in range(10): + x += 1 +print(x) \ No newline at end of file diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 35e5f13..61636db 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -17,7 +17,8 @@ while x < 10: print(x) x = x + 2 - + Guess:Going forever + Actual:prints 0,2,4.6,8 all on seprate lines 2. What does this program print out? x = 1 @@ -25,6 +26,9 @@ print(x) x = x * 2 + Guess:print 1,2,4,8,16,32 all on seprate lines + Acutal:print 1,2,4,8,16,32 all on seprate lines + 3. Why is the and x >= 0 not needed? x = 0 @@ -32,6 +36,8 @@ print(x) x = x + 2 + You dont need to check for things that can never be false + 4. What does this program print out? (0 pts) Explain. (1 pt) x = 5 @@ -41,6 +47,7 @@ print("Blast off!") x = x - 1 + Answer: It will never run blast off 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) @@ -58,7 +65,7 @@ x - 1 print("Blast-off") - + X is not defined. 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) @@ -66,7 +73,7 @@ for i in range(10): print(i) i += 1 - + remove the 1 += 1 8. Explain why the values printed for x are so different. (2 pts) # Sample 1 @@ -85,4 +92,4 @@ x += 1 print(x) - + Sample 1 only prints 110 while Sample 2 prints 1 to 110. From c9ba45c7714a901a85cac9425b9b561b50db74cb Mon Sep 17 00:00:00 2001 From: Jake Faucett Date: Thu, 16 Nov 2017 13:00:02 -0600 Subject: [PATCH 5/5] CHapter 6 completed --- Lab 03 - Create a Quiz/main_program.py | 10 +++- Lab 06 - Loopy Lab/part_1.py | 16 ++++++ Lab 06 - Loopy Lab/part_2.py | 21 +++++++- Lab 06 - Loopy Lab/part_4.py | 68 ++++++++++++++++++++++++++ 4 files changed, 113 insertions(+), 2 deletions(-) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index 792d600..6e8d828 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -1 +1,9 @@ -# +#!/user/bin/env python3 +#chap6.py +#Jake Faucett +#11/13/17 + +print('Quiz Time!') + +input('What side of my head do I have a implant on? ') +if "Left" \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 8b13789..31db579 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1 +1,17 @@ +#!/user/bin/env python3 +#loopy lab +#Jake Faucett +#11/16/17 +#Start at 10 for the triangle +begin = 10 +#Do this 9 times +for row in range(9): + # Loop to print the digits + for j in range(row +1): + #prints the variable + print(begin, end= ' ') + #Adds 1 to start so the line is higher + begin += 1 + #Prints a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 792d600..1d1061f 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1 +1,20 @@ -# +#!/user/bin/env python3 +#loopy lab +#Jake Faucett +#11/16/17 +n= int(input('E.g. n = ')) + +#Variable for spaces +spaces = (n*2) - 2 + +#print the o times the variable and times 2 +print('o' * ((n)*2)) + +#loop variable -1 +for i in range(1, n-1): + +#print the o's + spaces times and then place another o + print('o' + (' '*spaces) + 'o') + +#print the final row of o's times the varaible and 2 +print('o'*(n)*2) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 792d600..1ca4f36 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -1 +1,69 @@ # +#!/user/bin/env python3 +#loopy lab +#Jake Faucett +#11/16/17 + +""" + 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) +GREEN = (0, 255, 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 y in range(0,500,10): + for x in range(0,700,10): + pygame.draw.rect(screen, GREEN, [x, y, 5, 5],0) + print() + # --- 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()