0% found this document useful (0 votes)
7 views1 page

Advanced Python Programming Examples

The document provides a series of programming exercises in Python covering if-else statements, loops, functions, and lists. It includes tasks such as checking if a number is positive or negative, printing numbers and their squares, creating functions, and manipulating lists of colors. Each exercise is designed to enhance understanding of basic Python programming concepts.

Uploaded by

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

Advanced Python Programming Examples

The document provides a series of programming exercises in Python covering if-else statements, loops, functions, and lists. It includes tasks such as checking if a number is positive or negative, printing numbers and their squares, creating functions, and manipulating lists of colors. Each exercise is designed to enhance understanding of basic Python programming concepts.

Uploaded by

priyanshsr22
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Advanced Python

If-Else:
1. Write a program that takes an integer as input and prints "Positive" if it is greater
than 0, otherwise prints "Negative or Zero".
2. Write a program that checks whether a number is even or odd using an if-else
statement.

Loops:

3. Write a Python program using a for loop to print numbers from 1 to 10.
4. Write a for loop to print the square of numbers from 1 to 5.
5. Write a Python program using a while loop to print all even numbers from 2 to 20.

Functions:
6. Write a Python function called greet() that prints "Hello, welcome to Python
programming!" when called.
7. Write a function add_numbers(a, b) that takes two numbers as input and returns
their sum.

Lists:

8. Create a list of five colors ("red", "blue", "green", "yellow",


"black") and use a for loop to print each color.
9. Write a Python program to add a new color "white" to the list in Question 6 and
print the updated list.

You might also like