Week 3/4: Turtle & Statements Flashcards

1
Q

Turtle uses the _________ Coordinate
System?

A

Turtle uses the Cartesian Coordinate
System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Relational Operators?

A

= < > ,etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Week 3 review:
How to change the colors of Python’s turtle.

A

turtle.pencolor(“green”)
turtle.fillcolor(“purple”)
turtle.color(“pink”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name the 4 logical operators learned this week and a brief description.

A

else=The else statement is used to execute a block of code when none of the preceding if or elif conditions are true.
if (&nested if)=code to execute if something is true.
and=testing sets of conditions
elif=short for else if. If no test has been successful yet, an elif tries something else.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does == and != mean?

A

== is equal
!= is not equal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What should a code look like, with if, elif, and else?

A

If c == d
if x == y:
g = h
elif a == b
g = h
else: e = f
else:
e = f

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Comments start with # and do not execute, what else can it do?

A

Test lines of code to help deduce why a code is failing. # can also be added in the middle of a line and will not hinder the outcome.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to form a Decision Structure condition?

A

create a logical expression that evaluates to either “true” or “false” using comparison operators like “greater than”, “less than”, “equal to”, and logical operators like “AND”, “OR”, and “NOT”, based on the variables or values you want to check in your program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is 1 test condition and 1 path of the following code?
grade = 85

if grade >= 90:
print(“Excellent”)
elif grade >= 80:
print(“Good”)
elif grade >= 70:
print(“Average”)
else:
print(“Below Average”)

A

test condition: if grade >=90
path: if grade is 90 or higher, the program prints “Excellent”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a truth table?
A B A AND B A OR B
False False False False
False True False True
True False False True
True True True True

A

Table to display truth values of logical expressions based on their inputs. Shows AND & OR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the order of precedence?

A

not: Evaluate not True, which results in False.
and: Evaluate False and True, which results in False.
or: Evaluate False or False, which results in False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to determine an else statement is odd or even?

A

Modulo (% symbol). Example:
num = 4
if num % 2 == 0:
print(str(num) + “is an even number”)
else:
print(str(num) + “is an odd number”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In Java (an IDE), IF statements use what character?
Hint: Python (an IDE) uses :

A

Curvy parentheses }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the steps to Data Munging/Data Wrangling?

A
  1. Sorting
  2. Filtration
  3. Reduction
  4. Access
  5. Processing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Data Munging/Data Wrangling? What might you do during this?

A

The process of transforming and cleaning raw data into a more usable format. Like removing/correcting errors in the data, filling in missing values, standardizing data formats, combining data from different sources, and filtering out irrelevant information. The goal is to prepare the data for analysis. Python may use the Panda library, which can include a CSV file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What would
.strip()
and
.lower()
do?

A

.strip()
removes whitespace

.lower()
makes everything lower-case

17
Q

What are the 3 errors?

A

Syntax error: missing character like a :

Run time error: output works, data type is wrong/missing like converting a float to an integer.

Logic errors: program is running but code isn’t working. Hardest to find.

18
Q

How would you define the variable for:

IF snow >= 5
print(“Yeah! We have a snow day!”)

A

snow = int(input(“Enter snow accumulation on ground in inches: “)

19
Q

How to say if something is between #s?

A

IF 3 <= VARIABLE <=12:

20
Q

Concatenate to say each are done with their project:
name1 = “Bob”
name2 = “Sue”

A

result = name1 + “‘s done and “ + name2 + “‘s done”
print(result)

21
Q

What will show?
my_variable = “ I Am Capitalised”
print(my_variable)
my_stripped = my_variable.strip()
print(my_stripped)
my_lower = my_variable.lower()
print(my_lower)

A

(Indent)I Am Capitalised
I Am Capitalised
i am capitalised

22
Q

What steps to take in their order.
X > 12 or X <= 5 and Y > 5 and Z < 15 or not(Z == 2)

A

parenthesis, and, simplify and, or, simplify or

23
Q

If 10 cartons are knocked down, what will the prize be and why?
If cartons > 12 then
Prize = “Teddy Bear”
End if
If cartons > 8 then
Prize = “Baseball Hat”
End if
If cartons > 6 then
Prize = “Jump Rope”
End if
If cartons > 5 then
Prize = “Candy Bar”
Else
Prize = “nothing”
End if

A

Candy Bar because there are IF statements. If they were ELSE, it would be Baseball Hat.