ITS PYTHON PROGRAMMING PRACTICE EXAM 2 COMPLETE LATEST FINAL EXAM UPDATED FOR 2025- 2026, Exams of Programming Languages

ITS PYTHON PROGRAMMING PRACTICE EXAM 2 COMPLETE LATEST FINAL EXAM UPDATED FOR 2025- 2026 ACTUAL QUESTIONS WITH 100% CERTIFIED, ELABORATED & VERIFIED SOLUTIONS- TOP SCORE ACE YOUR EXAMS Using the dropdown arrows for the missing code pieces, complete the following code example so that it accomplishes the functionality of this game: A user gets five chances to correctly guess a whole number from 1 to 10. If the user guesses correctly, they get a congratulatory message and the game ends. If not, they get a message thanking them for playing. from random import randint

Typology: Exams

2025/2026

Available from 01/14/2026

SCHOLARA-STUVIA-HUB
SCHOLARA-STUVIA-HUB ๐Ÿ‡บ๐Ÿ‡ธ

3.7

(6)

8K documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ITS PYTHON PROGRAMMING PRACTICE EXAM 2 COMPLETE LATEST FINAL EXAM
UPDATED FOR 2025- 2026 ACTUAL QUESTIONS WITH 100% CERTIFIED,
ELABORATED & VERIFIED SOLUTIONS- TOP SCOREโœ“โœ“โœ“ ACE YOUR EXAMS
Using the dropdown arrows for the missing code pieces, complete the following code example
so that it accomplishes the functionality of this game:
A user gets five chances to correctly guess a whole number from 1 to 10. If the user guesses
correctly, they get a congratulatory message and the game ends. If not, they get a message
thanking them for playing.
from random import randint
randint(1,10)
A developer wants documentation for a function to display when called upon in a print
statement. Use the drop-down menus to fill in the remainder of the code necessary to generate
the documentation.
'''
'''
area.__doc__
Examine the following code:
def area (width, height):
area=width*height
return area
box1area=area(5,2)
box2area=area(6)
What needs to change in order for the height in the area function to be 12 if a height is not
specified when calling the function?
def to def area (width, height=12)
The proper syntax for pydoc is Python -m pydoc module where module represents the name of
a Python module.
Yes
Pydoc is a self-contained executable that can be run from a command-line prompt.
No
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download ITS PYTHON PROGRAMMING PRACTICE EXAM 2 COMPLETE LATEST FINAL EXAM UPDATED FOR 2025- 2026 and more Exams Programming Languages in PDF only on Docsity!

ITS PYTHON PROGRAMMING PRACTICE EXAM 2 COMPLETE LATEST FINAL EXAM

UPDATED FOR 2025- 2026 ACTUAL QUESTIONS WITH 100% CERTIFIED,

ELABORATED & VERIFIED SOLUTIONS- TOP SCORE โœ“โœ“โœ“ ACE YOUR EXAMS

Using the dropdown arrows for the missing code pieces, complete the following code example so that it accomplishes the functionality of this game: A user gets five chances to correctly guess a whole number from 1 to 10. If the user guesses correctly, they get a congratulatory message and the game ends. If not, they get a message thanking them for playing. from random import randint randint(1,10) A developer wants documentation for a function to display when called upon in a print statement. Use the drop-down menus to fill in the remainder of the code necessary to generate the documentation. ''' ''' area.doc Examine the following code: def area (width, height): area=width*height return area box1area=area(5,2) box2area=area(6) What needs to change in order for the height in the area function to be 12 if a height is not specified when calling the function? def to def area (width, height=12) The proper syntax for pydoc is Python - m pydoc module where module represents the name of a Python module. Yes Pydoc is a self-contained executable that can be run from a command-line prompt. No

Pydoc generates documentation of Python modules. Yes A junior programmer enters the following code: height= width= if height==width print("You have a square") When trying to run the code, errors are generated. Which two fixes are necessary in order for this code to work? A colon needs to be added at the end of the if condition. The print statement needs to be indented. A new Python developer is learning the code necessary to display dates in multiple formats. The developer has been tasked to create the following display with dates: 2023 - 01 - 01 The current date is 01/01/ The current weekday is: 6 Using the dropdown arrows, complete the code snippet necessary to create the display, leaving open the possibility of the time being displayed in the future. import datetime datetime,datetime.now() %m/%d/%Y weekday() Evaluate the following code example, whcih is an attempt to loop through and print a tuple of products by serial numher: products=("1111","2222","3333","4444","5555","6666","7777","8888","9999") for product in products: print(products[product]) The code, when run, is generating errors. Which fixes are needed to make the code work properly and return the list of products? Change the print statement to print(product) Indent the print statement

for student in range(1,11): print(f"Student{student}_______") You are writing code to have activity for every day in a 30-day program. There should be no activity on day 15. Using the dropdown arrows, fill in the missing pieces to the code. for 31 continue You need to write code that sends northern sales staff skis and everyone else gold balls if they exceed sales of $100,00 for a month. The staff should only get skis if the season is winter. Using drag and drop, arrange the code pieces needed in the correct order. Not every code snippet will be will be used. if monthlySales> if region=="North" && season=="Winter": print(Send Skis) else print(Send golf balls) You are writing code to list cities and then delete, from the list, any city that has more than five letters in the name. Using the dropdown arrows, fill in the missing pieces of code needed to complete the code needed to fulfill this task. len remove Evaluate the following code: def score_adj(score,rank): new_score=score if score>3000 and rank>3: new_score+= else: new_score+=

return new_score score1=score_adj (3000,3) score2=score_adj(2000,2) score3=score_adj(5000,5) print(score1, score2, score3) For each statement regarding the results of code, indicate a Yes if the statement is true and No if the statement is false. score1= score3= score2= No Yes No You are trying to generate 10 sets of random numbers. One random number is between 3 and 99, with the number being a multiple of 3. The other random number needs to be between 0 and 1. Drag the snippets of code needed to complete the code block, which a small part of a game app. randrange(3,102,3) random() A developer wants to print the first line of a configuartion file. The code to perform this tast is written as follows: #import module if os.path.isfile('config.txt;): with open('config.txt','r') as file: print(file.#read the first line) Which code snippets are needed to replace the comments and finish this code example? readline() import. os.path A developer is setting up several assert tests for an app. The tests are as follows: test1 should test to see if a calculation is true or false.

open w write close() You want to write text from a user input. The file may exist, so your code needs to account for both the existence of the file and the lack of existence of the file. If the file does exist, next text to needs to be written to a new line. Using drag and drop, finish the code. Not all options will be used. a w n You are in the process of writing code to delete a file if it exists or just display a message indicating that there was no file to remove if the file does not exist. Using the dropdown arrows, select the proper code pieces to finish this code example. os isfile remove What would be the value of result that prints at the end of this code? a= b= c= result=a+b*c print(result) 38 Evaluate the following code and then select Yes for any true statement related to the code and No for any false statement related to the code: import math a=- 14 b= c=math.fabs(a) d=math.fmod(b,a) e=math.frexp(b)

frexp returns the mantissa and exponent of a number c== d==1. Yes Yes No Using the drag and drop, match each expression with its proper default data type. Boolean Integer String Float False 1 "False"

Evaluate the following code: def is_quarter(num): if num%4==0: return True else: return False assert is_quarter(8)==True What will the code return? Nothing You are building a quiz app using Python. The code is missing an operator to indicate that a variable is not equal to a desired result. Using the dropdown arrow, choose the correct operator to finish the code. != Evaluate the following code. For each statement regarding the results of the calculation, select Yes if the statement is true and NO if the statement is false. a=

No No Yes A developer is writing code to iterate prining and state, with the end result looking like this: Orange Florida Orange Ohio Orange Illinois Springfield Florida Springfield Ohio Springfield Illinois Capital Auburn Florida Auburn Ohio Auburn Illinois The first two lines of code are as follows: cities=["Orange","Springfield","Auburn"] states=["Florida","Ohio","Illinois"] Using the dropdown arrows, complete the code necessary to generate the above output. for x in cities: for y in states: if x=="Springfield" and y=="Illionois": Pow is a build-in math function that raises the first number indicated to the power of the second number indicated. Sqrt returns the square root of a number. Isqrt returns the integer of square root of a number. To use these functions, the math module must first be imported. Thus, the correct code is as follows: math pow(a,b) sqrt(a) isqrt(b) A junior programmer is building a function to compute the area of a rectangle. Which function definition statement is needed to replace the comment to make this code work? #declare function here

z=xy print(z) area(5,10) def area(x,y): Evaluate the following code, used to set up a unit test between two variables. import unittest class TestMain(unittest.TestCase): def_________(self): a='North' b='North' self.assertEqual(a,b) if__name___=='main': unittest.main() Of the function names given, which function name is a valid name for the function building the unit test? test_territory Example the following code, used to calculate total cost for renting storage space for a day: length=12. price=2. cost=lengthprice print("Your total cost is", cost) The total cost is not printing as a dollar amount, as the number of decimal places vary. Which print statement would print the total cost as two decimals, using the Modulo operator? print("Your total cost is %.2f" % (cost)) Using the drag and drop, arrange each group of operators in the correct order of precedence, with the highest precedence on top. Arithmetic Containment Comparison Identity Logical Assignments

No Yes Yes