The correct response is break point.
Which is a set point that tells the debugger when to pause the execution of code?(1 point)
Responses
pause point
pause point
set point
set point
break point
break point
stop point
7 answers
When there is an error or a flaw in the lines of code in computer science then what it is termed as?(1 point)
Responses
compiler
compiler
Boolean
Boolean
bug
bug
objec
Responses
compiler
compiler
Boolean
Boolean
bug
bug
objec
The correct response is bug.
def discount_on_voucher(voucher, amount):
discount = 0
if voucher == 'Flat 50':
discount = 0.5 * amount
elif voucher == 'Flat 30':
discount = 0.3 * amount
elif voucher == 'Flat 20':
discount = 0.2 * amount
return discount
disc = discount_on_voucher('Flat 75', 1000)
print(f'Discount is {disc}')
What will be the output of the code? Execute your code using the Trinket.
Trinket
(1 point)
Responses
The output will be “Discount is 200.”
The output will be “Discount is 200.”
The output will be “Discount of 1000.”
The output will be “Discount of 1000.”
The output will be “Discount is 0.”
The output will be “Discount is 0.”
The output will be “Discount is 150.”
discount = 0
if voucher == 'Flat 50':
discount = 0.5 * amount
elif voucher == 'Flat 30':
discount = 0.3 * amount
elif voucher == 'Flat 20':
discount = 0.2 * amount
return discount
disc = discount_on_voucher('Flat 75', 1000)
print(f'Discount is {disc}')
What will be the output of the code? Execute your code using the Trinket.
Trinket
(1 point)
Responses
The output will be “Discount is 200.”
The output will be “Discount is 200.”
The output will be “Discount of 1000.”
The output will be “Discount of 1000.”
The output will be “Discount is 0.”
The output will be “Discount is 0.”
The output will be “Discount is 150.”
The output of the code will be “Discount is 0.”
This is because the voucher 'Flat 75' does not match any of the conditions in the if
and elif
statements, so the discount
remains 0.
user = {
'name': 'Bruce',
'Address' : 'Gotham',
'subscription' : {
'title' : 'Student Bundle',
'cost' : 1000
}
}
print(user.get('subscription').get('title'))
What will be the output of the code? Execute the code using the Trinket.
Trinket
(1 point)
Responses
It will throw a KeyError
It will throw a KeyError
Bruce
Bruce
Student Bundle
Student Bundle
1000
'name': 'Bruce',
'Address' : 'Gotham',
'subscription' : {
'title' : 'Student Bundle',
'cost' : 1000
}
}
print(user.get('subscription').get('title'))
What will be the output of the code? Execute the code using the Trinket.
Trinket
(1 point)
Responses
It will throw a KeyError
It will throw a KeyError
Bruce
Bruce
Student Bundle
Student Bundle
1000
The output of the code will be Student Bundle.
The print
statement accesses the subscription
dictionary within the user
dictionary and retrieves the value associated with the title
key, which is 'Student Bundle'.