Podcast
Questions and Answers
What will be the output of the following code? total = 0
for count in [1,2,3]:
total = total + count
print(total)
What will be the output of the following code? total = 0 for count in [1,2,3]: total = total + count print(total)
Which of the following correctly describes a list in Python?
Which of the following correctly describes a list in Python?
What does the following code return? def pass_it(x, y):
z = str(x) + ", " + str(y)
answer = pass_it(4, 8)
print(answer)
What does the following code return? def pass_it(x, y): z = str(x) + ", " + str(y) answer = pass_it(4, 8) print(answer)
What is the valid index for extracting 'New York' from the string: city = 'New York city'?
What is the valid index for extracting 'New York' from the string: city = 'New York city'?
Signup and view all the answers
In Python, what will the expression phones['John'] evaluate to after this code executes? phones = {'John' : '5555555', 'Julie' : '5557777'}
phones['John'] = '5556666'
In Python, what will the expression phones['John'] evaluate to after this code executes? phones = {'John' : '5555555', 'Julie' : '5557777'} phones['John'] = '5556666'
Signup and view all the answers
Which of the following statements about dictionaries is true?
Which of the following statements about dictionaries is true?
Signup and view all the answers
What is the correct way to read data from the keyboard in Python?
What is the correct way to read data from the keyboard in Python?
Signup and view all the answers
What will happen if line 1 is removed, and 'divTags' is replaced with 'soup' in lines 2 and 3?
What will happen if line 1 is removed, and 'divTags' is replaced with 'soup' in lines 2 and 3?
Signup and view all the answers
What is the purpose of the 'try' and 'except' block in the error handling code?
What is the purpose of the 'try' and 'except' block in the error handling code?
Signup and view all the answers
What will the print statement inside the 'for' loop located at line 6 display?
What will the print statement inside the 'for' loop located at line 6 display?
Signup and view all the answers
What is the outcome of the provided code snippet that extracts the first tag?
What is the outcome of the provided code snippet that extracts the first tag?
Signup and view all the answers
Given the URL format for searching on Amazon, which aspect needs to change to create a search link for 'data science'?
Given the URL format for searching on Amazon, which aspect needs to change to create a search link for 'data science'?
Signup and view all the answers
How does the 'p.get_text().strip()' function assist in data cleaning?
How does the 'p.get_text().strip()' function assist in data cleaning?
Signup and view all the answers
Why might a data scientist use a loop to create search URLs for Amazon?
Why might a data scientist use a loop to create search URLs for Amazon?
Signup and view all the answers
What will the variable 'data1' store after lines 4 to 11 are executed?
What will the variable 'data1' store after lines 4 to 11 are executed?
Signup and view all the answers
Which code correctly extracts the value of the class attribute of all the
tags in the given html_code?
Which code correctly extracts the value of the class attribute of all the
tags in the given html_code?
Signup and view all the answers
What is the output of the code 'soup.find_all(class_="food", limit=1)' in relation to extracting
tags?
What is the output of the code 'soup.find_all(class_="food", limit=1)' in relation to extracting
tags?
Signup and view all the answers
Which statement is true about 'soup.find('h1', id="top", class="food")'?
Which statement is true about 'soup.find('h1', id="top", class="food")'?
Signup and view all the answers
How many
tags will 'soup.body.find_all("p", recursive=False)' return?
How many
tags will 'soup.body.find_all("p", recursive=False)' return?
Signup and view all the answers
What does the code 'soup.find_all("p", string="Cauliflower Fritters")' do?
What does the code 'soup.find_all("p", string="Cauliflower Fritters")' do?
Signup and view all the answers
Which code does not print the
tag object that contains 'Cauliflower Fritters'?
Which code does not print the
tag object that contains 'Cauliflower Fritters'?
Signup and view all the answers
What is the expected output from 'print(soup.find("h1", attrs ={ "id":"top" ,"class":"sister" }))'?
What is the expected output from 'print(soup.find("h1", attrs ={ "id":"top" ,"class":"sister" }))'?
Signup and view all the answers
Which of these statements describes the structure of the HTML provided?
Which of these statements describes the structure of the HTML provided?
Signup and view all the answers
Study Notes
True or False Questions
- Math expressions in Python are not always evaluated from left to right. They follow operator precedence rules.
- Repeating operations in Python use loops.
- Python supports multiple arguments.
- Code snippet displaying "yes + no" is incorrect.
- Code checking if
choice
is not 10 is correct.
Multiple Choice Questions
- The
input()
function gets input from the keyboard. -
input()
returns a string. - Output of
print(valuel * value2)
is 24.0 , givenvaluel = 2.0
andvalue2 = 12
. - A comma-separated sequence of data items enclosed in square brackets is a list.
- Output of
total = 0; for count in [1, 2, 3]: total = total + count; print(total)
is 6. - Output of
def pass_it(x, y): z = str(x) + ", " + str(y); num1 = 4; num2 = 8; answer = pass_it(num1, num2); print(answer)
is "4, 8". - Valid index values for extracting 'New York' from 'New York city' include 0:8, :8, and 0:-5.
- Dictionaries are not indexed by number.
- Output of
phones = {'John':'5555555','Julie':'5557777'}; phones['John']='5556666'; print(phones)
is{'John':'5556666','Julie':'5557777'}
.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.