100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Tentamen (uitwerkingen)

ITS Python Practice Exam 2 - Python Programming Correctly Answered.

Beoordeling
-
Verkocht
-
Pagina's
14
Cijfer
A+
Geüpload op
06-04-2025
Geschreven in
2024/2025

ITS Python Practice Exam 2 - Python Programming Correctly Answered. 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. - CORRECT ANSWER 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. - CORRECT ANSWER ''' ''' 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? - CORRECT ANSWER 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. - CORRECT ANSWER Yes Pydoc is a self-contained executable that can be run from a command-line prompt. - CORRECT ANSWER No Pydoc generates documentation of Python modules. - CORRECT ANSWER Yes A junior programmer enters the following code: height=5 width=5 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? - CORRECT ANSWER 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: The current date is 01/01/2023 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. - CORRECT ANSWER import datetime datetime,() %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? - CORRECT ANSWER Change the print statement to print(product) Indent the print statement You are in the process of writing some code to divide two numbers. You want the result to display so long as there are no errors. If there are errors, you want to display a message indicating that the user either tried to divide by zero or used an invalid number. Using the dropdown arrows, fill in the missing keywords to make this happen. - CORRECT ANSWER try except a=float(input("Enter a number.")) b=float(input("Enter a number to divide by.")) try: print("This did not work. Did you try to divide by zero?") else: print("You successfully divided two numbers.") finally: print("Thank you for playing.") The finally statement will run regardless of which pieces of code above it run. Both the try and except parts will run if a=0 and b!=0. The else part will run if a=0 and b!=0 - CORRECT ANSWER Yes No Yes

Meer zien Lees minder
Instelling
PYTHON.
Vak
PYTHON.









Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
PYTHON.
Vak
PYTHON.

Documentinformatie

Geüpload op
6 april 2025
Aantal pagina's
14
Geschreven in
2024/2025
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

ITS Python Practice Exam 2 - Python
Programming Correctly Answered.

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. - CORRECT ANSWER 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. -
CORRECT ANSWER '''

'''

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? - CORRECT ANSWER 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. - CORRECT ANSWER Yes

, Pydoc is a self-contained executable that can be run from a command-line prompt. - CORRECT ANSWER
No



Pydoc generates documentation of Python modules. - CORRECT ANSWER Yes



A junior programmer enters the following code:

height=5

width=5

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? - CORRECT ANSWER 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/2023

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. - CORRECT ANSWER 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")
€11,35
Krijg toegang tot het volledige document:

100% tevredenheidsgarantie
Direct beschikbaar na je betaling
Lees online óf als PDF
Geen vaste maandelijkse kosten


Ook beschikbaar in voordeelbundel

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
ROSEGRADES Nursing
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
214
Lid sinds
2 jaar
Aantal volgers
87
Documenten
12161
Laatst verkocht
1 week geleden
TOPGRADE

I HELP STUDENTS WITH REVISION MATERIALS WITH BETTER GRADES GUARANTEED. BEST OF LUCK.

3,4

30 beoordelingen

5
10
4
3
3
11
2
2
1
4

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen