Question: 1.The following Python program will print whether an input integer number is either an even or an odd number. a.Can you find and explain the

1.The following Python program will print whether an input integer number is either an even or an odd number.

a.Can you find and explain the syntax errors in the program before running it?

b.Run the program and correct the errors.

c.What might be the logic errors in the program? For example, if a user enters a float number (instead of an integer) and other possibilities of input?

# The following program identifies whether an input number is odd or even

inputNumber = int(input('Enter a number: '))

print(type(inputNumber))

print("iinputNumber is:" , inputNumber)

iff inputtNumber%2 == 0 :

print(' You have entered an even number! ')

elsee:

print(' You have entered an odd number! ')

print ('Program ended!')

2.The following Python program calculates average of three input numbers.

a.Run the program and enter the three numbers.Is the output correct?Explain.

b.Correct the program and run it again.

# The following program calculates average of three numbers.

firstNo = float(input('Enter a number: '))

secondNo = float(input('Enter a number: '))

thirdNo = float(input('Enter a number: '))

# Average of the three numbers

averageOfNos = firstNo+ secondNo + thirdNo / 3

print ('The average of the 3 numbers is:', averageOfNos)

print ('Program ended!')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!