
Python Practice Test
Authored by Marissa Montes
Information Technology (IT)
12th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
40 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Evaluate the following Python Practice Test arithmetic expression: (3*(1+2)**2 - (2**2)*3) What is the result?
A. 3
B. 13
C. 15
D. 69
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Northwind Traders has hired you as an intern on the coding team that creates e-commerce applications. You must write a script that asks the user for a value. The value must be used as a whole number in a calculation, even if the user enters a decimal value. You need to write the code to meet the requirements. Which code segment should you use?
A. totalltems = int(input(”How many items would you like?”))
B. totalltems = str(input(”How many items would you like?”))
C. totalltems = float(input(”How many items would you like?”))
D. totalltems = input(”How many items would you like?”)
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You are creating a Python Practice Test program that shows a congratulation message to employees on their service anniversary. You need to calculate the number of years of service and print a congratulatory message. You have written the following code. Line numbers are included for reference only. start = input(”How old were you on your start date?) end = input(’How old are you today?”) You need to complete the program. Which code should you use at line 03?
A. print(“congratulations on “ + int(end - start) + “ years of service!”)
B. print(“congratulations on “ + (int(end) - int(start)) + “ years of service!”)
C. print(“congratulations on “ + str(end - start) + “ years of service!”)
D. print(”congratulations on “ + str(int(end) - int(start)) + “ years of service!”)
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You develop a Python Practice Test application for your company. You want to add notes to your code so other team members will understand it. What should you do?
A. Place the notes after the last line of code separated by a blank line.
B. Place the notes inside of parentheses on any line.
C. Place the notes after the # sign on any line.
D. Place the notes before the first line of code separated by a blank line.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
You are writing an application that uses the sqrt function. The program must reference the function using the name squareRoot. You need to import the function. Which code segment should you use?
A. from math import sqrt as squareRoot
B. from math.sqrt as squareRoot
C. import math.sqrt as squareRoot
D. import sqrt from math as squareRoot
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
This question requires that you evaluate the underlined text to determine if it is correct. You write the following code: import sys try: file_in = open(”in.txt”, ‘r’) file_out = open(”out.txt”, ‘w+’) except lOError: print(’cannot open’, file_name) else: i = 1 for line in file_in: print(line. rstrip()) file_out.write(”line “ + str(i) + “: “ + line) i = i + 1 file_in.close() file_out.close () The out.txt file does not exist. You run the code. The code will execute without error. Review the underlined text. If it makes the statement correct, select “No change is needed.” If the statement is incorrect, select the answer choice that makes the statement correct.
A. No change is needed.
B. The code runs but generates a logic error.
C. The code will generate a runtime error.
D. The code will generate a syntax error.
7.
MULTIPLE SELECT QUESTION
30 sec • 1 pt
You are writing a Python Practice Test program to automate inventory. Your first task is to read a file of inventory transactions. The file contains sales from the previous day, including the item id, price, and quantity. The code must meet the following requirements: Each line of the file must be read and printed. If a blank line is encountered, it must be ignored. When all lines have been read, the file must be closed. You create the following code. Line numbers are included for reference only. inventory = open(”inventory.txt”, ‘r’) eof = False hile eof == False: line = inventory.readline() Which code should you write for line O5 and line 06?
A. 05 if line != ‘‘: 06 if line !=””:
B. 05 if line != ‘ ’: 06 if line != None:
C. 05 if line != ‘ ’: 06 if line != “”:
D. 05 if line != ‘‘: 06 if line != “ ”:
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
40 questions
UAS SMP Informatika Kelas IX 2024-2025
Quiz
•
9th Grade - University
35 questions
NILAI PRA PAT KELAS 11 B
Quiz
•
11th Grade - University
35 questions
ms excel kelas 6
Quiz
•
6th Grade - University
35 questions
Latihan Soal Informatika Kelas 7
Quiz
•
7th Grade - University
40 questions
CSS 3rd Quarter Examination
Quiz
•
11th Grade - University
40 questions
DAMPAK SOSIAL INFORMATIKA
Quiz
•
9th - 12th Grade
42 questions
Asesmen Sumatif
Quiz
•
12th Grade
35 questions
UH Materi Ms. Word
Quiz
•
7th Grade - University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
Discover more resources for Information Technology (IT)
20 questions
-AR -ER -IR present tense
Quiz
•
10th - 12th Grade
12 questions
Add and Subtract Polynomials
Quiz
•
9th - 12th Grade
13 questions
Model Exponential Growth and Decay Scenarios
Quiz
•
9th - 12th Grade
27 questions
7.2.3 Quadrilateral Properties
Quiz
•
9th - 12th Grade
7 questions
Amoeba Sisters Dihybrid Cross Punnett Square
Interactive video
•
9th - 12th Grade
10 questions
The Holocaust: Historical Overview
Interactive video
•
9th - 12th Grade
10 questions
Key Features of Quadratic Functions
Interactive video
•
8th - 12th Grade
11 questions
Exponent Quotient Rules A1 U7
Quiz
•
9th - 12th Grade