Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python programming 1. [2 marks] Explain what is wrong with the following loop and rewrite it so that it works properly. # This Loop should

python programming

image text in transcribed
1. [2 marks] Explain what is wrong with the following loop and rewrite it so that it works properly. # This Loop should count down from 100 to 0 in steps of 5 X = 100 while x >= 0: print (x - 5) 2. [2 marks] Explain the meaning of the error message produced by the following code. The error message is: TypeError: '>' not supported between instances of 'int' and 'str' s1 = "Something" $2 = "else" print (len(s1) > s2) 3. [2 marks] Explain the meaning of the error message produced by the following code. The error message is: TypeError: 'tuple' object does not support item assignment data = (12, 7, 1996) data[-1] += 1 4 . [4 marks] Write an input-validation loop to get a user's age as a valid integer, then print their age in 10 years. Your code should produce the output below (user input follows the "Age: " prompt): Age: five :) Invalid integer Age : Invalid integer Age : -1 Age must be between 0 and 120 Age: 121 Age must be between 0 and 120 Age : 0 In 10 years, you will be 10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions