0% found this document useful (0 votes)
4 views9 pages

Functions

The document outlines a series of Python programming tasks, including functions for multiplying numbers in a list, reversing a string, calculating factorials, checking number ranges, counting uppercase and lowercase letters, creating a unique list, checking for prime numbers, and determining if a string is a palindrome. It also explains the difference between formal and actual parameters in function definitions. Additionally, there is a task to calculate the sum of the digits of a number.

Uploaded by

flixpog
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)
4 views9 pages

Functions

The document outlines a series of Python programming tasks, including functions for multiplying numbers in a list, reversing a string, calculating factorials, checking number ranges, counting uppercase and lowercase letters, creating a unique list, checking for prime numbers, and determining if a string is a palindrome. It also explains the difference between formal and actual parameters in function definitions. Additionally, there is a task to calculate the sum of the digits of a number.

Uploaded by

flixpog
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

FUNCTIONS

1. Write a Python function to multiply all the numbers in a [Link] List : (8, 2, 3, -1, 7)
Expected Output : -336

2. Write a Python program to reverse a string. Sample String : "1234abcd" Expected Output :
"dcba4321"
3. Write a Python function to calculate the factorial of a number (a non-negative integer).
The function accepts the number as an argument.
4. Write a Python function to check whether a number is in a given range.
5 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
6. 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]

7. Write a Python function that takes a number as a parameter and check the number is prime
or not.
8. 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.
10. Explain the difference between formal and actual parameters

Formal Parameters

These are the variables defined in a function’s definition (header).


They act as placeholders for the values the function will receive when called.

Actual Parameters (Arguments)

These are the real values (or variables) passed to the function when it is called.
They replace the formal parameters during execution.

11. Write a function to calculate the sum of the digits of a number passed as a parameter.

You might also like