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

Python Assignment-8

This document outlines 13 Python programming assignments involving functions to find the max of three numbers, sum and multiply numbers in lists, reverse strings, check if numbers are in a given range or perfect, determine if a string is a palindrome, print the first n rows of Pascal's triangle, and create and print a list of squares of numbers between 1 and 30. The assignments cover topics like working with lists, strings, numbers, and defining functions.

Uploaded by

Himanshu Yadav
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)
66 views

Python Assignment-8

This document outlines 13 Python programming assignments involving functions to find the max of three numbers, sum and multiply numbers in lists, reverse strings, check if numbers are in a given range or perfect, determine if a string is a palindrome, print the first n rows of Pascal's triangle, and create and print a list of squares of numbers between 1 and 30. The assignments cover topics like working with lists, strings, numbers, and defining functions.

Uploaded by

Himanshu Yadav
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
You are on page 1/ 1

Python Lab: Assignment-8 (18/10/2022)

No Programs
1. Write a Python function to find the Max of three numbers.
2. Write a Python function to sum all the numbers in a list.
Sample List : (8, 2, 3, 0, 7)
Expected Output : 20
3. Write a Python function to multiply all the numbers in a list.
Sample List : (8, 2, 3, -1, 7)
Expected Output : 336
4. Write a Python program to reverse a string.
Sample String : "1234abcd"
Expected Output : "dcba4321"
5. Write a Python function to check whether a number falls in a given range.
6. Write a Python function that accepts a string and calculate the number of upper case
letters and lower case letters.
Sample String : 'The quick Brow Fox'
Expected Output :
No. of Upper case characters : 3
No. of Lower case Characters : 12
7. Write a Python function that takes a list and returns a new list with unique elements of
the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
8. Write a Python function that takes a number as a parameter and check the number is
prime or not.
Note : A prime number (or a prime) is a natural number greater than 1 and that has no
positive divisors other than 1 and itself.
9. Write a Python program to print the even numbers from a given list.
Sample List : [1, 2, 3, 4, 5, 6, 7, 8, 9]
Expected Result : [2, 4, 6, 8]
10. Write a Python function to check whether a number is perfect or not.
Example: The first perfect number is 6, because 1, 2, and 3 are its proper positive
divisors, and 1 + 2 + 3 = 6. Equivalently, the number 6 is equal to half the sum of all its
positive divisors: ( 1 + 2 + 3 + 6 ) / 2 = 6. The next perfect number is 28 = 1 + 2 + 4 +
7 + 14. This is followed by the perfect numbers 496 and 8128.
11. Write a Python function that checks whether a passed string is palindrome or not.
Note: A palindrome is a word, phrase, or sequence that reads the same backward as
forward, e.g., madam or nurses run.
12. Write a Python function that prints out the first n rows of Pascal's triangle.
Note : Pascal's triangle is an arithmetic and geometric figure first imagined by Blaise
Pascal.
13. Write a Python function to create and print a list where the values are square of
numbers between 1 and 30 (both included).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy