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 does the pop() method do to a list?
Removes the last element and returns it
Removes the first element and return it
Removes a specific element
Sorts the list
2
What is a function in Python?
A loop
A variable
A data type
A reusable block of code
3
What is the output of this code snippet?
Adult
Error
18
Minor
4
Which of the following is NOT a valid data type in Python?
String
Integer
Character
Float
5
How do you define a function in Python?
def my_function():
function my_function():
define my_function():
my_function = function():
6
How do you convert a string to uppercase in Python?
upper(string)
string.toUpperCase()
string.upperCase()
string.upper()
7
Which list method adds an element to the END of a list?
extend()
insert()
append()
add()
8
How do you access the first element of a list called my_list?
my_list[1]
my_list.first()
my_list.get(1)
my_list
9
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
10
What is Python commonly used for?
Data Analysis
Web Development
All of the above
Artificial Intelligence
11
What data type is my_learner =[1]
Set
List
Tuple
Dictionary
12
How do you sort a list permanently in alphabetical order?
sorted(list)
list.sort()
sort(list)
list.sorted()
13
What is the result of print(2 + 2) in Python?
22
4
2 + 2
Error
14
Which keyword removes an element from a list by its INDEX?
delete
pop
remove
del
15
Which of the following is a conditional statement in Python?
def
for
while
if
16
How would you refer to a module named "math" in your code?
add math
import math
get math
include math
17
What is the output of print(10 / 5)?
0.5
50
2
2.0
18
How do you print "Hello, World!" in Python?
print("Hello, World!")
console.log("Hello, World!")
System.out.println("Hello, World!")
print "Hello, World!"
19
What is the purpose of a for loop?
To store data
To check a condition
To define a function
To execute a block of code repeatedly
20
What will print(greet("World")) output, given the function:
Hello, World
Hello, name!
Hello, World!
Error