Question

In: Computer Science

For each of the following Python errors provide a scenario that would cause it: TypeError AttributeError...

For each of the following Python errors provide a scenario that would cause it:

  • TypeError
  • AttributeError
  • IndexError
  • ValueError
  • ZeroDivisionError
  • IndentationError

Solutions

Expert Solution

Ans:

# it generates type error
# here we are concatinating string with integer
print("st"+5)

# it generates attribute error
# integer variable val has no attribute append
val=10
val.append(20)

# index error occurs if we try to access something that is not exist
# here lst have length 3 so, indices ranges from 0 to 2 only. so accessing index 4 generates error.
lst=[1,2,3]
print(lst[4])

# if we try to convert to some other datatype that can't be convertable
# here "dog" cannot be converted to int
val=int("dog")

# ZeroDivisonError occurs if we divison with 0
res=5/0

# Indentation error occurs if we don't follow correct indentation
# here after for loop , the content of for loop must be inside(a tab space) of it.

lst=[1,2,3,4]
for val in lst:
print(val)


Related Solutions

In this python script find any bugs and errors which would cause the code to crash....
In this python script find any bugs and errors which would cause the code to crash. The code must be re-written correctly. After debugging make a separate list of all the errors you found in the script. contacts_list=[] # global variable, list of contacts_list, one string per contact def pause()     """ pauses program e.g. to view data or message """     input("press enter to continue") def load():     """ populate list with data """          contacts_list.append(('Milo ', '063847489373'))...
For each of the following errors, considered individually, indicate whether the error would cause the adjusted...
For each of the following errors, considered individually, indicate whether the error would cause the adjusted trial balance totals to be unequal. If the error would cause the adjusted trial balance totals to be unequal, indicate whether the debit or credit total is higher and by how much. 1 The adjustment for accrued wages of $5,550 was journalized as a debit to Wages Expense for $5,550 and a credit to Accounts Payable for $5,550. --- A. The totals are equal....
Which of the following errors, each considered individually, would cause the trial balance totals to be...
Which of the following errors, each considered individually, would cause the trial balance totals to be unequal? a.Cash received from customers on account was posted as a debit of $720 to Cash and a credit of $720 to Accounts Payable. b.A payment of $4,450 to a creditor was posted as a debit of $4,500 to Accounts Payable and a credit of $450 to Cash. c.A payment of $67 for insurance was posted as a debit of $76 to Prepaid Insurance...
For each of the following errors, considered individually, indicate whether the error would cause the trial...
For each of the following errors, considered individually, indicate whether the error would cause the trial balance totals to be unequal. If the error would cause the trial balance totals to be unequal, indicate whether the debit or credit total is higher and by how much. If the debit and credit totals would be equal, enter zero ("0") in the amount box. a. The payment of an insurance premium of $7,450 for a three-year policy was debited to Prepaid Insurance...
Which of the following errors would cause the adjusted trial balance to not​ balance? A. posting...
Which of the following errors would cause the adjusted trial balance to not​ balance? A. posting the debit for accrued interest to insurance expense B. reversing the debits and credits in an adjusting entry C. failure to post one side of a journal entry D. omitting the adjusting entry for depreciation expense 2. Permanent accounts do not include​ ________. A. Rent Expense B. Interest Receivable C. Prepaid Insurance D. Taxes Payable
Which of the following errors would cause the trial balance to be out of​ balance? A.The...
Which of the following errors would cause the trial balance to be out of​ balance? A.The payment of an account payable for $200 was recorded as a debit to Accounts Payable for $200 and a credit to Cash for $2,000. B.The payment of an account payable for$400 was recorded as a debit to​ Cash, $400​,and a credit to Accounts​ Payable, $400. C.The payment of utilities expense was recorded as a debit to Rent Expense for $77and a credit to Cash...
Review the list of common titration errors. Determine whether each error would cause the calculation for...
Review the list of common titration errors. Determine whether each error would cause the calculation for moles of analyte to be too high, too low, or have no effect. adding titrant past the color change of the analyte solution recording the molarity of titrant as 0.1 M rather than its actual value of 0.01 M spilling some analyte out of the flask during the titration starting the titration with air bubbles in the buret filling the buret above the 0.0...
Trial Balance Errors For each of the following errors, considered individually, indicate whether the error would...
Trial Balance Errors For each of the following errors, considered individually, indicate whether the error would cause the trial balance totals to be unequal. If the error would cause the trial balance totals to be unequal, indicate whether the debit or credit total is higher and by how much. If the debit and credit totals would be equal, enter zero ("0") in the amount box. a. The payment of an insurance premium of $7,450 for a three-year policy was debited...
For each of the following errors, describe to a recently hired bookkeeper how it would be...
For each of the following errors, describe to a recently hired bookkeeper how it would be shown on a cash reconciliation: The bank recorded a deposit of $200 as $2,000. The company's bookkeeper mistakenly recorded a deposit of $530 as $350. The company's bookkeeper mistakenly recorded a payment of $250 received from a customer as $25 on the bank deposit slip. The bank caught the error and made the deposit for the correct amount. The bank statement shows a check...
what effect would each of the following errors have on the determined concentration of the unknown...
what effect would each of the following errors have on the determined concentration of the unknown acid? (would the calculated value be too high, too low, or unchanged? a) the mass of oxalic acid was recorded too low. b) the unknown acid was added to a flask containing 10 mL of water. c) the initial volume in the standardization was recorded too high. d) the initial volume in the determination of the unknown was recorded too high.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT