stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Python Basics Flashcards | StudBud
Explore
/
Python Basics
Python Basics
20 terms
·
StudBud Administration
·
8 plays
Test your knowledge on fundamental concepts and syntax of the Python programming language
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
What is a function in Python?
A loop
A data type
A variable
A reusable block of code
2
How do you sort a list permanently in alphabetical order?
list.sorted()
list.sort()
sorted(list)
sort(list)
3
How do you convert a string to uppercase in Python?
string.upper()
string.toUpperCase()
string.upperCase()
upper(string)
4
How do you print "Hello, World!" in Python?
print("Hello, World!")
print "Hello, World!"
System.out.println("Hello, World!")
console.log("Hello, World!")
5
What is the result of print(2 + 2) in Python?
Error
22
4
2 + 2
6
Which of the following is a conditional statement in Python?
for
def
while
if
7
What is Python commonly used for?
All of the above
Artificial Intelligence
Data Analysis
Web Development
8
How do you write a single-line comment in Python?
// This is a comment
# This is a comment
' This is a comment
/* This is a comment */
9
Which list method adds an element to the END of a list?
add()
insert()
extend()
append()
10
What does the pop() method do to a list?
Removes a specific element
Sorts the list
Removes the first element and return it
Removes the last element and returns it
11
How do you define a function in Python?
def my_function():
function my_function():
my_function = function():
define my_function():
12
How would you refer to a module named "math" in your code?
get math
add math
import math
include math
13
Which keyword removes an element from a list by its INDEX?
pop
remove
del
delete
14
What data type is my_learner =[1]
Tuple
List
Set
Dictionary
15
What is the purpose of a for loop?
To check a condition
To execute a block of code repeatedly
To store data
To define a function
16
What will print(greet("World")) output, given the function:
Error
Hello, World!
Hello, name!
Hello, World
17
How do you access the first element of a list called my_list?
my_list
my_list.first()
my_list[1]
my_list.get(1)
18
What is the output of this code snippet?
Minor
Error
18
Adult
19
What is the output of print(10 / 5)?
0.5
2.0
50
2
20
Which of the following is NOT a valid data type in Python?
Character
Float
String
Integer