Question: Basic Python Programming 3 test runs for each question Control Statements (if and loops) 1.Write a program to determine whether a person is eligible (18

Basic Python Programming

3 test runs for each question

Control Statements (if and loops)

1.Write a program to determine whether a person is eligible (18 years old) to vote or not.

If not eligible, display how many years are left to be eligible. (use if else)

Sample Run 1

>>>

Enter the age : 10

You have to wait for another 8 years to cast your vote

Sample Run 2

>>>

Enter the age : 25

You are eligible to cast your vote

2.Write a program to find whether the given number is even or odd. (use if else)

Sample Run 1

>>>

Enter any number : 125

125 is odd

Sample Run 2

>>>

Enter any number : 12

12 is even

3.Write a program to determine whether the character entered is a vowel(a-e-i-o-u) or not. (use if-elif-else)

Sample Run 1

>>>

Enter any character : h

h is not a vowel

Sample Run 2

>>>

Enter any character : e

e is a vowel

4.Write a program to take single character input from the user and then check whether it is a number or a character. If it is a character, determine whether it is in uppercase or lowercase. If it is a number display A number was entered. The digits '0' to '9' are characters.

Sample Run 1

>>>

Enter any character : C

Uppercase character was entered

Sample Run 2

>>>

Enter any character : b

Lowercase character was entered

Sample Run 3

>>>

Enter any character : 2

A number was entered

5.Write a program to print the number of horizontal asterisks * .

User input an int number. (use while loop only)

Sample Run

>>>

How many stars do you want? 20

6.Write a program to calculate the property tax. User enters the lot number and property value. Use while loop keep entering lot and calculate value until user enters a sentinel of -999 to end program. Tax factor is 0.0065. Property tax = property value X tax factor

Sample Run

>>>

Enter the property lot number or enter -999 to end

Enter the lot number : 100

Enter property value : 100000.00

Property tax : $650.00

Enter the property lot number or enter -999 to end

Enter the lot number : 200

Enter property value : 5000.00

Property tax : $32.50

Enter the property lot number or enter -999 to end

Enter the lot number : -999

7. Write a program using while loop with validation where user input wholesale prices to calculate retail prices. The markup is 2.5 times. Validation is to check if a value is out of range and display a message to let the user know that the value entered is an error. In this case the wholesale value cannot be less than zero.

Sample Run 1

>>>

Enter the items wholesale cost: -.50

ERROR: the cost cannot be negative

Enter the correct wholesale cost: .50

Retail price is $1.25

Do you have another item?

(Enter y for yes): n

Sample Run 2

Enter the items wholesale cost: .75

Retail price is $1.88

Do you have another item?

(Enter y for yes): Y

Enter the correct wholesale cost: .50

Retail price is $1.25

Do you have another item?

(Enter y for yes): n

8.Write a for loop using range() function to print Barzinger 5 times.

Barzinger

Barzinger

Barzinger

Barzinger

Barzinger

(one test run only for this question)

9.Write a program that uses a for loop to calculate the sum of numbers. The user will specify how many numbers to sum.

Sample Run

>>>

How many numbers do you want to add? 3

Enter number 1 : 25

Enter number 2 : 34

Enter number 3 : 33

The total is 92.0

10.Write a program using for loop to convert speeds from 60kph through 130kph (in 10 kph increments) to mph. The formula: mph = kph * conversion factor where conversion factor is 0.6214. (one test run only for this question)

Sample Run

>>>

KPH MPH

------------------------------------

60 37.3

70 43.5

80 49.7

90 55.9

100 62.1

110 68.3

120 74.6

130 80.8

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 Databases Questions!