-
Which is a set point that tells the debugger when to pause the execution of code?
- break point
-
When there is an error or a flaw in the lines of code in computer science then what is it termed as?
- bug
-
What will be the output of the code?
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}')
- The output will be “Discount is 0.” (Since 'Flat 75' does not match any of the conditions.)
-
What will be the output of the code?
user = { 'name': 'Bruce', 'Address' : 'Gotham', 'subscription' : { 'title' : 'Student Bundle', 'cost' : 1000 } } print(user.get('subscription').get('title'))
- Student Bundle
-
Demonstrate how can we display the value of key “year” using the get method in the code.
user = { 'name': 'Parker', 'Address' : 'London', 'subscription' : { 'title' : 'Student Bundle', 'cost' : 1000, 'valid_till' : { 'month': 'Jan', 'year': 2022, 'date': 2 } } } print(user.get('subscription').get('valid_till').get('year'))
- print(user.get('subscription').get('valid_till').get('year'))
Which is a set point that tells the debugger when to pause the execution of code?(1 point)
stop point
break point
set point
pause point
When there is an error or a flaw in the lines of code in computer science then what it is termed as?
(1 point)
compiler
Boolean
object
bug
Use the code to answer the question.
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)
The output will be “Discount is 0.”
The output will be “Discount is 150.”
The output will be “Discount is 200.”
The output will be “Discount of 1000.”
Use the code to answer the question.
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)
1000
Student Bundle
It will throw a KeyError
Bruce
Use the code to answer the question.
user = {
'name': 'Parker',
'Address' : 'London',
'subscription' : {
'title' : 'Student Bundle',
'cost' : 1000,
'valid_till' : {
'month': 'Jan',
'year': 2022,
'date': 2
}
}
}
Demonstrate how can we display the value of key “year” using the get method in the code.
(1 point)
print(user.get('valid_till').get('subscription').get('year'))
print(user.['subscription']['valid_till']['year'])
print(user.get(subscription).get(valid_till).get(year))
print(user.get('subscription').get('valid_till').get('year'))
1 answer