0% found this document useful (0 votes)
14 views10 pages

Python Exercises v1

The document contains a series of Python programming exercises aimed at beginners, covering various topics such as input/output, arithmetic operations, string manipulation, and control flow using loops. Each exercise includes a question followed by a placeholder for the solution. The exercises are designed to help learners practice and improve their Python coding skills.

Uploaded by

obbynyemba19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views10 pages

Python Exercises v1

The document contains a series of Python programming exercises aimed at beginners, covering various topics such as input/output, arithmetic operations, string manipulation, and control flow using loops. Each exercise includes a question followed by a placeholder for the solution. The exercises are designed to help learners practice and improve their Python coding skills.

Uploaded by

obbynyemba19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Python Exercises

(part 1)

Question no.1. Write a program in Python which asks you to input any number of hours
& converts it into seconds?

SOLUTION:

Question no.2. Write a program in Python which asks you to input two numbers &
returns the sum of them?

SOLUTION:

Question no.3. Write a program in Python that asks you to enter two numbers, compares
them & tells you which of them is bigger or both are equal?
Python
SOLUTION:
Exercises 1
Networkwalks Academy

Cisco Certifications www.networkwalks.com [email protected]


Question no.4. Write a program in Python that asks you to enter a text string & returns
string 'a' replaced with ' 0' (for example, networkwalks should be returned as networkw0lks)

SOLUTION:

Question no.5. Write a program in Python that asks you to enter a text string & tells you
its length?

SOLUTION:

1 www.networkwalks.com [email protected]
Question no.6. Write a program in Python that will produce following output using For
loop:

SOLUTION:

2 www.networkwalks.com [email protected]
Question no.7. Write a program in Python that will produce following output using
While loop:

SOLUTION:

Question no.8. Write a program in Python which asks you to input two numbers &
returns the average of them?

SOLUTION:

3 www.networkwalks.com [email protected]
Question no.9. Write a program in Python that will produce following output:

SOLUTION:

Question no.10. What will be the output of following Python code?

var1 = 1
var2 = 2
var3 = "3"
print(var1 + var2 + var3)

SOLUTION:

4 www.networkwalks.com [email protected]
Question no.11. What will be the output of following Python code?

var1 = 1
var2 = 2
var3 = "3"
print(var1, var2, var3)

SOLUTION:

Question no.12. What will be the output of following Python code?

a = 3 + 2 * 4 + 4
print(a)

SOLUTION:

Question no.13. What will be the output of following Python code?

x = 8 + 8 * 9
print(x)

SOLUTION:

5 www.networkwalks.com [email protected]
Question no.14. What will be the output of following Python code?

i = 8 + 8 * 9 + 9 (10-9)
print(i)

SOLUTION:

Question no.15. What will be the output of the following Python code?

p, q, r = 10, 20 ,30
print(p, q, r)

SOLUTION:

Question no.16. Write a program in Python, using For loop, that asks you to enter a
text string & then prints its letters separately?

SOLUTION:

6 www.networkwalks.com [email protected]
Question no.17. Write a program in Python that will produce following output
using only one Print function command (do not use print function more than once, do no use
loop or other functions):

*
* *
* *
* *
*** ***
* *
* *
*****

*Hint: Use Print function & \n in a single line command.

SOLUTION:

7 www.networkwalks.com [email protected]
Question no.18. Write a program in Python that will produce following output
using 8x Print function commands (use print function eight times, do no use loop or other
functions):

*
* *
* *
* *
*** ***
* *
* *
*****

SOLUTION:

Question no.19. Write a program in Python that will produce following output
using for Loop:

*
* *
* * *
Hint: Use nested for loop (for loop inside another for loop)

SOLUTION:

8 www.networkwalks.com [email protected]
Question no.20. Write a program in Python that will produce following output
using for Loop:

*
* *
* * *
* * * *
* * * * *
Hint: Use nested for loop (for loop inside another for loop)

SOLUTION:

© All Rights are reserved, Network Walks Academy


Leave your feedback at: [email protected]. Your Technical Questions, comments & suggestions are always Welcomed.
www.networkwalks.com

9 www.networkwalks.com [email protected]

You might also like