Programming with Python Quiz

Questions: 16 · 10 minutes
1. Given palette = (""red"", ""green""), which statement creates a new tuple containing ""blue"" while leaving palette unchanged?
palette.append(""blue"")
expanded = list(palette).append(""blue"")
palette[2] = ""blue""
expanded = palette + (""blue"",)
2. Which condition uses Python’s identity test to check specifically for the singleton value None?
result is None
result = None
not result
type(result) is null
3. In Python 3, what is the data type of the value 3.5?
float
int
decimal
str
4. What does bool({}) evaluate to in Python?
True, because a dictionary object exists
False, because the dictionary is empty
None, because the dictionary has no entries
An error, because dictionaries cannot become Boolean values
5. What is the result of the expression ""7"" + ""3""?
The string ""73""
The string ""10""
An error because strings cannot use +
The integer 10
6. Which built-in Python collection is mutable?
tuple
frozenset
list
str
7. In Python 3, what are the value and type of 5 / 2?
2 with type int
2.5 with type float
2.0 with type float
2.5 with type decimal
8. What value is produced by 7 // 2?
3
4
1
3.5
9. What is the result of {1, 1, 2} == {1, 2}?
A TypeError, because sets cannot be compared
False, because the left side originally contains three entries
False, because sets compare insertion order
True, because duplicate set entries are not retained
10. What does this code print? first = [1, 2] second = first second.append(3) print(first)
[1, 2], because append affects only second
[1, 2, 3], because both names refer to the same list
[3], because append replaces the original values
An error, because lists cannot be assigned to two names
11. What value is assigned to total? total = int(""12"") + 3
The string ""123""
A TypeError caused by mixing a string and an integer
The integer 15
A ValueError caused by converting ""12""
12. What does this code print? tags = {""python"", ""quiz"", ""python""} print(len(tags))
3, because three values were entered
1, because all values have the same data type
An error, because sets cannot contain strings
2, because a set keeps unique values
13. What does this code print? profile = {""age"": 30} profile[""age""] += 1 print(profile[""age""])
30
The string ""301""
A KeyError
31
14. What is the result of letters[1:4] when letters = ""abcdef""?
""abc""
""bcd""
""bcde""
""cde""
15. What does this code print? a, b = (4, 9) print(a + b)
(4, 9)
The string ""49""
13
An error because tuples cannot be unpacked
16. Which value can be used as a dictionary key in Python?
A list containing ""north"" and ""south""
A set containing ""north"" and ""south""
A tuple containing ""north"" and ""south""
A dictionary mapping ""region"" to ""north""
Popular tests
Narcissistic Personality Inventory (NPI)
This self-report measure is used to assess narcissism as a personality trai…
Start Test
Yale-Brown Obsessive Compulsive Scale (Y-BOCS)
This measure is used to rapidly quantify the current severity of obsessive…
Start Test
CRAFFT Screening Test (CRAFFT 2.1)
This brief screening measure is designed to identify potential alcohol and…
Start Test
Patient Health Questionnaire-9 (PHQ-9)
This measure is commonly used to quickly screen for the presence and severi…
Start Test
Maslach Burnout Inventory (MBI)
This self-report measure is used to assess occupational burnout symptoms in…
Start Test
Adolescent Anxiety Questionnaire
This measure is designed to support a brief appraisal of anxiety symptoms a…
Start Test
Emotional Creativity Inventory (ECI)
This self-report measure assesses individual differences in the originality…
Start Test
Horne–Ostberg Morningness–Eveningness Questionnaire (MEQ)
Circadian preferences influence typical patterns of alertness and sleep tim…
Start Test
Ambivalent Sexism Inventory (ASI)
This measure is designed to assess attitudes toward women, including both o…
Start Test
Internalized Misogyny Scale (IMS)
This measure is designed to assess internalized negative beliefs and stereo…
Start Test
Perceived Stress Scale (PSS-10)
This self-report measure assesses the degree to which individuals appraise…
Start Test
Impulsive Behavior Scale (SUPPS-P)
Impulsivity is a multidimensional construct that is often assessed with bri…
Start Test
Clinical Institute Withdrawal Assessment for Alcohol, Revised (CIWA-Ar)
This rating scale is used to rapidly assess the severity of alcohol withdra…
Start Test
Positive and Negative Affect Schedule (PANAS)
This measure provides a brief self-report assessment of current or typical…
Start Test
Light Triad Scale (LTS)
This self-report measure assesses prosocial personality tendencies and orie…
Start Test
Suicidal Ideation Scale
In clinical settings, the Suicidal Ideation Scale is used to structure an i…
Start Test
Body Dysmorphic Disorder Scale (BDD-D)
This brief self-report measure is designed to screen for and quantify distr…
Start Test
Beck Anxiety Inventory (BAI)
This measure is a brief self-report inventory used to screen for anxiety sy…
Start Test
Differential Test of Perfectionism
This instrument is used to screen for perfectionism-related attitudes and t…
Start Test
Locus of Control Scale
This measure assesses generalized expectancies regarding the degree to whic…
Start Test
New Apathy Scale
This brief self-report measure is used to screen for apathy-related symptom…
Start Test
Perth Alexithymia Questionnaire (PAQ)
This measure assesses individual differences in alexithymia, including diff…
Start Test
Social Intelligence Scale
This brief self-report measure is designed to support rapid screening of in…
Start Test
Fear Test
This measure is designed to evaluate individual differences in fear-related…
Start Test
Neuroticism Level Scale
The measure is intended for brief screening of an individual’s propensity t…
Start Test
Aggressiveness Indicators Screening Questionnaire
This screening tool is designed to quickly identify behavioral indicators a…
Start Test