NEW
Font size
WorksheetsPython L1 Quiz 8: Designing Programs
Total questions: 10
Worksheet time: 30mins
True or False: We can create a turtle inside a python class
True
False
True or False: Once you draw something with turtle, you can't get user input from the keyboard afterward.
True
False
When creating a flowchart to model a program, a diamond shape usually represents a:
terminator (the start or end of the program)
process
decision
variable
Why are flowcharts useful?
They allow us to visualize the logic of our program
They make it easier to explain your code to others
They help you to understand when to use functions and flow controls when writing the program
All of these are reasons why flowcharts are useful
What is pseudocode?
It means 'false code' and is the name given to code that has errors in it
It is a plan of a program written in words that resemble code
It is an object-oriented language that is easier to read than python
It is a style of writing comments that help the user to understand what is going on in the program
Which is true about python programs?
You can only have one class per python file
Code in a function is not run until the function is called
An object cannot contain another object as a variable
You have to call the __init__ method of an object after it is created
In our adventure game, the state variable tells us:
The player's current progress through the story, like a save point
What region of the game world the player is in
The condition of the player, like health points and status
Whether the player is a solid, liquid, or gas
How can we make sure our program ignores capitalization when comparing text input?
Ask the user to follow the capitalization pattern that you coded
Create if statements to check for every likely capitalization pattern
Ignore text that isn't capitalized the same way as you wrote it
Use .lower() to change the input string to lowercase and then compare
A while loop works well for the main part of our adventure game because:
It will keep repeating the same part of the game code forever
It will repeat the same steps for a set number of rounds of the game
It will repeat the same process until the player wins, loses, or quits the game
It will repeat the same process until one of the players sets a new high score
Creating classes and objects in our adventure game code is helpful because:
We could write a class that holds all the possible user input text and outcomes
We could easily change the map and reuse the map class to make maps for other games
Having classes allowed us to control two turtles in the same program
Creating objects makes the game run faster
