Data Types, Conditions, Loops, and Lists in Python

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/15

flashcard set

Earn XP

Description and Tags

Flashcards from lecture notes

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

16 Terms

1
New cards

What data type is: 1

Integer

2
New cards

What data type is: 1.0

Float

3
New cards

What data type is: "1.0"

String

4
New cards

What data type is: True

Boolean

5
New cards

If the user types in Fred, what will the code print out?

"What are you doing, Fred?"

6
New cards

What is the error in the code on line 18?

Missing colon at the end of the if statement if (survivor == "A" or survivor == "a")

7
New cards

What is the error in the code on line 18?

Missing equals sign in the if statement if (survivor == "A" or survivor == "a)

8
New cards

What is the error in the code on line 17?

Missing input function name. survivor input("What type of survivor are you? A, T, I or M: ")

9
New cards

What is the error in the code on line 18?

Missing equals sign for comparison in the if statement if (survivor == "A" or survivor = "a"):

10
New cards

When will this code stop asking you "What type of survivor are you? A, T, I or M:"?

The code will stop asking "What type of survivor are you? A, T, I or M:" when the user inputs A, a, T, or t

11
New cards

What will this code print out?
survivors = ['A', 'T', 'I']
i = 0
for survivor in survivors:
print(i)
i += 1

0, 1, 2

12
New cards

What does line 98 do? What is it equivalent to?
i += 1

Line 98 increments the counter i by 1. It's equivalent to i = i + 1

13
New cards

When will this code accept the user input?
food = ["Burger", "burger", "Shake", "Fries"]
userinput = input("What would you like today?") if (userinput in food):
print("Great I added a", user_input)

Never, it compares the user input against the list values and will do different things based on the content.

14
New cards

What should I set the index to so that the code will print out True?
myList = [0, 1.0, "Fred", True]
index =

3

15
New cards

What list is not defined correctly and why?
list1 = [ ]
list2 =
list3 = [0,1,2,3]
list4 = ["0 1 2 3"]

list3 = [0123] is not defined correctly, because it’s missing commas between each value

16
New cards

Does ORDER matter for importing a library?
import math
MRES = math.ceil(totalCalories / caloriesPerMRE)

Yes, the order matters.