0% found this document useful (0 votes)
8 views

Week 2 Exercises

excercise Payton

Uploaded by

csakshi661
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Week 2 Exercises

excercise Payton

Uploaded by

csakshi661
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Lecturer: Clive Gargan Programming Essentials

Programming Essentials (Python)

Conditional Logic or Selections or Decisions

Exercise 1

1. Write a program which reads two integer values. If the first number is less than the
second, print the message "First number is less than the second".
If the second is less than the first, print the message "Second number is less than the
first".
If the numbers are equal, print the message "The numbers are equal".

2. Write a program that prompts the user to enter age. If age of the user is equal to or
greater than 18, then the proram displays “You are eligibel to vote”. Otherwise the
program displays “You cannot vote”.

3. The Young and Beautiful Travel Company restricts its clients to ages between 18 and 30.
Write a program to input a client's age and test whether they are eligible to go on
vacation with the company or not.

4. Write a program to input a salary from the user and determine how much tax
someone should pay according to the following rules:
People pay no tax if they earn up to €10,000. They pay tax at the rate of 20% on the
amount they earn over €10,000 but up to €50,000. They pay tax at 40% on any money
they earn over €50,000.

5. Write a program that prompts the user for either 1, 2, 3 or 4.


In your python code you will need to print out what 1, 2, 3 and 4 correspond to using
below:
1 = diamonds, 2= hearts, 3= clubs and 4 = spades respectively.

6. Write a program which displays a menu to the user. The menu should look similar to the
following:

Welcome to the SimpleCacl

Press 1 to add two numbers

Press 2 to subtract two numbers

Press 3 to divide two numbers


Lecturer: Clive Gargan Programming Essentials

Press 4 to multiple two numbers

Read in the selection from the user and then ask the user for two numbers.

Print the result to the user.

You might also like