Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

ENGR 102 EXAM 1 QUESTIONS AND ANSWERS VERIFIED 100% CORRECT| GRADED A +|

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

ENGR 102 EXAM 1 QUESTIONS AND ANSWERS VERIFIED 100% CORRECT| GRADED A +| What must be true to convert from a string to an integer or float? - ANSWER There must be a "clearly" defined conversion. Examples: int('3') has the integer value of 3 float('3.14') has the float value of 3.14 float('2') has the float value of 2.0 int('2.5') has an ERROR since it cannot convert to a float and then to an int all in one step x = str(1/2) print(x) What would be the output of the previous? - ANSWER 0.5 Note: 0.5 would be a string and the operation of 1/2 is done before the conversion to a string x = str(10*1.0) print(x) What would be the output of the previous and what is the type of x? - ANSWER 10.0 Type of x: string How to convert from and to a boolean value? - ANSWER Using the bool() function x = 1 bool(x) When you convert FROM a boolean value what are True and False values assumed to be? - ANSWER True is assumed to have the value 1 False is assumed to have the value 0 When you convert TO a boolean value what numeric is False? - ANSWER The numeric value 0 has the value False and ANYTHING ElSE has the value True What value does x store in the following code? x = int(True) - ANSWER 1 What value does x store in the following code? x = float(True) - ANSWER 1.0 What value does x store in the following code? x = float(False) - ANSWER 0.0 What value does x store in the following code? x = bool(0) - ANSWER False What value does x store in the following code? x = bool(3) - ANSWER True What value does x store in the following code? x = bool('0') - ANSWER True Note: It is a string input within the bool function, NOT the numeric number 0 What value does x store in the following code? x = bool('') - ANSWER False Note: The empty string = 0 What value does x store in the following code? x = bool('False') - ANSWER True Note: 'False' Is NOT the numeric 0 How do you print more than one value or variable within the print statmenet? - ANSWER Separate them by commas Ex: print(2.0, 'is', 2) Output: 2.0 is 2 What is the output of the following? x = 3 y = 4 print(x, ':', y) - ANSWER 3 : 4 What is the output of the following? x = 3 y = 4 print(str(x) + ':' + str(y)) - ANSWER 3:4 What is the value of the following? "2.3".ljust(10) - ANSWER '2.3 ________' What is the value of the following? "2.3".rjust(10) - ANSWER '________2.3' What is the value of the following? "2.3".center(10) - ANSWER ' ____2.3____ ' How do you change how things are separated in the print statement? - ANSWER print(..., sep="something") How do you change what is done after printing? - ANSWER print(....,end="something") What is the output of the following print statements? print("Test", 3, 5, sep=',', end=':') print(15) - ANSWER Test,3,5:15 How do you use the format() function in python? - ANSWER string.format(values)

Meer zien Lees minder
Instelling
ENGR 102
Vak
ENGR 102

Voorbeeld van de inhoud

ENGR 102 EXAM 1 QUESTIONS AND
ANSWERS VERIFIED 100% CORRECT|
GRADED A +|


What must be true to convert from a string to an integer or float? - ANSWER There must be a
"clearly" defined conversion.
Examples:
int('3') has the integer value of 3 float('3.14')
has the float value of 3.14 float('2') has the
float value of 2.0
int('2.5') has an ERROR since it cannot convert to a float and then to an int all in one step

x = str(1/2)
print(x)
What would be the output of the previous? - ANSWER 0.5
Note: 0.5 would be a string and the operation of 1/2 is done before the conversion to a string
x = str(10*1.0) print(x)
What would be the output of the previous and what is the type of x? - ANSWER 10.0 Type
of x: string

How to convert from and to a boolean value? - ANSWER Using the bool() function
x=1
bool(x)

When you convert FROM a boolean value what are True and False values assumed to be? -
ANSWER True is assumed to have the value 1
False is assumed to have the value 0

, When you convert TO a boolean value what numeric is False? - ANSWER The numeric value 0
has the value False and ANYTHING ElSE has the value True

What value does x store in the following code?
x = int(True) - ANSWER 1

What value does x store in the following code?
x = float(True) - ANSWER 1.0

What value does x store in the following code?
x = float(False) - ANSWER 0.0

What value does x store in the following code?
x = bool(0) - ANSWER False

What value does x store in the following code?
x = bool(3) - ANSWER True

What value does x store in the following code?
x = bool('0') - ANSWER True
Note: It is a string input within the bool function, NOT the numeric number 0

What value does x store in the following code?
x = bool('') - ANSWER False
Note: The empty string = 0

What value does x store in the following code?
x = bool('False') - ANSWER True Note: 'False'
Is NOT the numeric 0

How do you print more than one value or variable within the print statmenet? - ANSWER
Separate them by commas
Ex:

, print(2.0, 'is', 2)
Output:
2.0 is 2

What is the output of the following?
x=3
y=4
print(x, ':', y) - ANSWER 3 : 4

What is the output of the following?
x=3
y=4
print(str(x) + ':' + str(y)) - ANSWER 3:4

What is the value of the following?
"2.3".ljust(10) - ANSWER '2.3 ________'

What is the value of the following?
"2.3".rjust(10) - ANSWER '________2.3'

What is the value of the following?
"2.3".center(10) - ANSWER ' ____2.3____ '

How do you change how things are separated in the print statement? - ANSWER print(...,
sep="<something>")

How do you change what is done after printing? - ANSWER print(....,end="<something>")

What is the output of the following print statements?
print("Test", 3, 5, sep=',', end=':')
print(15) - ANSWER Test,3,5:15

How do you use the format() function in python? - ANSWER <string>.format(<values>)

Geschreven voor

Instelling
ENGR 102
Vak
ENGR 102

Documentinformatie

Geüpload op
9 juni 2025
Aantal pagina's
29
Geschreven in
2024/2025
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$13.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

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.
TopGradeGuru Teachme2-tutor
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
15
Lid sinds
1 jaar
Aantal volgers
0
Documenten
2395
Laatst verkocht
2 maanden geleden
GRADEHUB

We provide access to a wide range of professionally curated exams for students and educators. It offers high-quality, up-to-date assessment materials tailored to various subjects and academic levels. With instant downloads and affordable pricing, it\'s the go-to resource for exam preparation and academic success.

1.5

2 beoordelingen

5
0
4
0
3
0
2
1
1
1

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

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen