
Python Practice Test

Quiz
•
Computers
•
University
•
Medium
Abdiel Vega
Used 2+ times
FREE Resource
56 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?
3
13
15
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?
totalltems = int(input(”How many items would you like?”))
totalltems = str(input(”How many items would you like?”))
totalltems = float(input(”How many items would you like?”))
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. 01 start = input(”How old were you on your start date?) 02 end = input(’How old are you today?”) You need to complete the program. Which code should you use at line 03?
print(“congratulations on “ + int(end - start) + “ years of service!”)
print(“congratulations on “ + (int(end) - int(start)) + “ years of service!”)
print(“congratulations on “ + str(end - start) + “ years of service!”)
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?
Place the notes after the last line of code separated by a blank line.
Place the notes inside of parentheses on any line.
Place the notes after the # sign on any line.
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?
from math import sqrt as squareRoot
from math.sqrt as squareRoot
import math.sqrt as squareRoot
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.
No change is needed.
The code runs but generates a logic error.
The code will generate a runtime error.
The code will generate a syntax error.
7.
MULTIPLE CHOICE 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 following shows a sample of data from the file: 10, 200, 5 20, 100, 1 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. 01 inventory = open(”inventory.txt”, ‘r’) 02 eof = False 03 hile eof == False: 04 line = inventory.readline() 05 06 07print(line) 08else: 09print(“End of file”) 10eof = True 11inventory.close() Which code should you write for line O5 and line 06?
05 if line != ‘‘: 06 if line !=””:
05 if line != ‘ ’: 06 if line != None:
05 if line != ‘ ’: 06 if line != “”:
05 if line != ‘‘: 06 if line != “ ”:
Create a free account and access millions of resources
Similar Resources on Wayground
51 questions
Java HF Chapter 1

Quiz
•
University
53 questions
Scratch Programming

Quiz
•
9th Grade - University
51 questions
ALGORITHM AND FLOWCHART

Quiz
•
12th Grade - University
60 questions
VBIT CSM-A PYTHON QUIZ 3

Quiz
•
University
55 questions
Marketing produk PKK

Quiz
•
10th Grade - University
60 questions
Salesforce

Quiz
•
University
60 questions
MATIQ PUTRI KELAS X - I

Quiz
•
10th Grade - University
58 questions
Mobile Computing (Lecture 2)

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
20 questions
Brand Labels

Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition

Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12

Lesson
•
11th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Computers
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
36 questions
Unit 5 Key Terms

Quiz
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
15 questions
Properties of Equality

Quiz
•
8th Grade - University
38 questions
WH - Unit 3 Exam Review*

Quiz
•
10th Grade - University
21 questions
Advise vs. Advice

Quiz
•
6th Grade - University
12 questions
Reading a ruler!

Quiz
•
9th Grade - University