CS 100

Logo

Scientific Computing

HW 1

Create a new folder in CS100 called hw. Download and save the file hw01.py to your CS100/hw folder.

This file is a template. It contains some code there for you. Put your name at the top of the file. Run it to test that it works. You should see the following in the python turtle graphics window:

There are 6 questions total. They are indicated in the code by the notation

### Q1 [point value]
### Description of question

All questions involve modifying a function in some way which is commented out. In order to test that your function works as expected, uncomment the function call and run your program.

Here is a visual of the solutions so you can use it to compare against to check that your answers are correct.

Question 1

When you are finished, you should see:

Question 2

When you are finished, you should see:

It’s okay if the black rectangle is located somewhere else, such as inside the red one.

Question 3

In the Thonny Shell area, you should see the following (in addition to the turtle graphics).

Answer to Q3: All numbers from -10 to 10
-10
-9
-8
-7
-6
-5
-4
-3
-2
-1
0
1
2
3
4
5
6
7
8
9
10

Question 4

In the Thonny shell, underneath your answers to question 3, you should see the following (in addition to the turtle graphics).

Answer to Q4: All numbers from 10 to -10
10
9
8
7
6
5
4
3
2
1
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10

Question 5

You should see the following now:

Question 6

You should see the following picture, now with the line shown below the red rectangle:

Question 7 - 10

You can work on these incrementally, but when you’re finished with all of them, it will show in the terminal

Answer to Q7:
4.0
Answer to Q8:
86400
Answer to Q9:
7.25
25.0
Answer to Q10:
Heather Guarnera

Note that the last one will vary based on your name :)

Grading

You will be graded based on your written program and that the output matches what is expected. In order to receive any credit, your program must run without syntax errors in Thonny. Thonny reports syntax errors in red in the shell area; if Thonny outputs an error, your code isn’t usable. Code that doesn’t run is just text - it’s not a program. It’s an important part of programming and problem solving to come up with a solution that can be shared with others.

Your program doesn’t have to be perfect to be eligible for credit! It’s okay to have some semantic errors. Semantic errors don’t stop your program from running, but they cause your program to produce an unexpected or incorrect result. For example, if your program is supposed to draw a square, but instead it draws a rectangle, that would be a semantic error. Semantic errors may result in partial credit depending on how close your solution is.

How to submit

Double check that your program runs without syntax errors. Submit the updated file hw01.py to Moodle.