Python Exercise Lists

# Python Condition Statement Exercises

1. Write a python program to get one word input from the user and then reverse it as another output. The following output can show one of the example

The output is:

Please input a word to reverse it: python

nohtyp

2. Write a python program to convert the temperature either from celsius to fahrenheit or from fahrenheit to celsius. To request the program user to input the temperature value with their F or C to represent fahrenheit or celsius. One of the example is shown below.

The output is:

Please input the temperature for convertion (e.g:101C, 30F): 40C

The temperature in Fahrenheit is 104 degrees.

3. Write a python program to calculate the number of even and odd numbers from a

The output is:

Please input the temperature for convert (e.g:101C, 30F): 40C

The temperature in Fahrenheit is 104 degrees.

4. Write a python program to guess a number between 1 to 10. When guessing correctly, pop out a message to inform the user. One of the example can be seen in the following output:

One of the example output is:

Guess a number between 1 and 10 until you get it right : 5
Guess a number between 1 and 10 until you get it right : 6
Guess a number between 1 and 10 until you get it right : 7
Guess a number between 1 and 10 until you get it right : 8
Guess a number between 1 and 10 until you get it right : 9
Guess a number between 1 and 10 until you get it right : 10
Congratulations, you guess correctly!

5. Write a python program to identify all the numbers which are divisible by 8 in between 200 and 500.

One of the example output is:

200,208,216,224,232,240,248,256,264,272,280,288,296,304,312,320,328,336,344,352,360, 368,376,384,392,400,408,416,424,432,440,448,456,464,472,480,488,496

6. Write a python program to all the items in a list_a as shown in the output below with their corresponding class of the items

The output is:

list_a = [1868, 2+5j, True, 'freelearningpoints', 1.52, {"Python user":123}, (2, -9), [6, 18]]

The class of 1868 is [class 'int'
The class of (2+5j) is [class 'complex']
The class of True is [class 'bool']
The class of freelearningpoints is [class 'str']
The class of 1.52 is [class 'float']
The class of {'Python user': 123} is [class 'dict']
The class of (2, -9) is [class 'tuple']
The class of [6, 18] is [class 'list']

7. Write a python program to iterate the numbers from 1 to 20. All the numbers which able to be multiplied by 3 replaced with 'Bee' and the numbers which able to be multiplied by 5 replaced with 'Jee'.

The output is:

Bee
0
1
2
Bee
3
4
Jee
5
Bee
6
7
8
Bee
9
Jee
10
11
Bee
12
13
14
Bee
15
16
17
Bee
18
19
Jee
20

8. Write a python program to print all the numbers from 1 to 20 except even number. Note that continue is an important statement to be used in this case.

The output is:

1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

9. Write a python program to request user to input the number of rows and columns therefore create a two-dimensional array. One of the example in the output below.

The output is:

Please input the columns number: 3
Please input the rows number: 4
[[0, 0, 0], [0, 1, 2], [0, 2, 4], [0, 3, 6]]

10. Write a python program to request user to input a word then calculate then number of input letter. One of the example in the output below.

The output is:

Letters 6

11. Write a python program to check the input number is an odd number or even number?

The output is:

Enter a number: 5
This is an odd number.

12. Write a python program to print out all the add numbers and only stop the printing immediately for the remaining numbers come after 88 based on the list_a provided in the following output

The output is:

numbers = [23, 66, 98, 56, 45, 78, 33, 52, 14, 65, 79, 90, 8, 35, 58, 60, 32, 48, 36, 68, 24, 80, 56, 78, 35, 88, 24, 56, 79, 43, 67, 32, 78, 43, 79, 66, 54, 78, 35, 78, 56, 89, 43, 67, 89, 43, 78, 98, 12, 61, 29, 35, 82, 49, 73, 56, 37 ]

23
45
33
65
79
35
35
88

13. Write two python program to print out the 5 symbols of "\$" without newline and another 5 symbols of "@" in newline

The output is:

\$\$\$\$\$

@
@
@
@
@

14. Write a python program to list out all the python modules which have installed in your local computer or laptop.

The output is:

jupyter-client==5.3.1
jupyter-console==6.0.0
jupyter-core==4.5.0
jupyter==1.0.0
jupyterlab-server==1.0.0
jupyterlab==1.0.2

15. Write a python program to identify the median number among three randomly input numbers from user.

The output is:

Please input the first number: 3
Please input the second number: 9
Please input the third number: 1
The median number of the above three numbers is 3

16. Write a python program to help the teacher to sum up the exam paper of part I and part II after that print out the result whether pass or fail. (Passing mark: 60)

The output is:

Please input machine learning Part I marks:
30
Please input machine learning Part II marks:
45
Congratulation, Pass!