Python Exercise Lists

Python Function Exercises

1. Write a python program to add in all the numbers with using function.

The output is:

numbers = (58, 5, 13, 1, 27)

Expected Answer:
The sum of number (58, 5, 13, 1, 27): 104

Click for the answer



2. Write a python program generate a function to find the maximum number among three numbers.

The output is:

numbers = (49, 66, -25)

Expected Answer:
The maximum number among three numbers: 66

Click for the answer



3. Write a python program generate a function to reverse the input value.

The output is:

input vale = Python3

Expected Answer:
The reverse of input: 3nohtyp

Click for the answer



4. Write a python program generate a function to multiply all the number in the following output.

The output is:

numbers = 2, 5, 7, 9, 1, 2

Expected Answer:
The multiplication of all the given numbers: 1260

Click for the answer



5. Write a python program generate a function to filter out the repeated string in a given list, list_a.

The output is:

list_a = [2,3,4,5,6,6,4,5]

Expected Answer:
The new list: [1, 2, 3, 4, 5]

Click for the answer



6. Write a python program generate a function to identify whether the specified number is in the range of initial value, list_a in the following output.

The output is:

list_a = [1, 2, 3, 4, 5, 6, 7, 8]
First number: 5
Second number: 9

Expected Answer:
First answer: 5 is in the range
Second number: The number 9 is outside the given range.

Click for the answer



7. Write a python program to generate a function to accept an input string therefore count the number of lowercase and uppercase respectively.

The output is:

input string = 'Welcome to learn Python on Freelearningpoints website'

Expected Answer:
The initial string is: Welcome to learn Python on Freelearningpoints website
The number of uppercase characters is: 3
The number of lowercase Characters is: 44

Click for the answer



8. Write a python program to generate a function to print out the odd number from a given list, list_a as provided in the following output.

The output is:

list_a = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]

Expected Answer:
The odd numbers: [3, 5, 7, 9, 11]

Click for the answer



9. Write a python program to generate a function to print out square number of a given list, list_a as provided in the following output.

The output is:

list_a = [2, 4, 6, 8, 10]

Expected Answer:
The square number is:
[4, 16, 36, 64, 100]

Click for the answer



10. Write a python program to generate a function to sum up four input values.

The output is:

values = 2, 5, 3, 6

Expected Answer:
The sum number is: 16

Click for the answer



11. Write a python program to generate a function to check whether the input alphabet is vowel or not.

The output is:

Input: letter "a" and "z"

Expected Answer:
Is letter 'a' a vowel: True
Is letter 'z' a vowel: False

Click for the answer



12. Write a python program to generate a function to combine different integer into one integer without undergoing normal mathematics operation.

The output is:

Integer list: [2, 8, 32, 6, 5]

Expected Answer:
The integers [2, 8, 32, 6, 5] are combined into: 283265

Click for the answer



13. Write a python program to generate a function to do the additional operation from different integer undergoing normal mathematics operation.

The output is:

Integer list: [2, 8, 32, 6, 5]

Expected Answer:
The summation of [2, 8, 32, 6, 5] is 53

Click for the answer



14. Write a python function to generate the addition of two input value, for addition result in the range of 30 to 35, change the result to 30.

The output is:

three sets of input values:
x = (10, 15)
y = (9, 22)
z = (32, 16)

Expected Answer:
25
30
48

Click for the answer



15. Write a python function to show the details of student name, student age, cumulative score, and course in University and arranged in four separate lines.

The output is:

Expected Answer:
Student name: Mason
Student age: 20
Cumulative score: 3.9
Course: Computer Science

Click for the answer



16. Write a python function to check whether the given list a and list b consist any repeated items.

The output is:

list_a = ['python', 'exercise', 'tutorial', 'practice']
list_b = 'python', 'exercise', 'tutorial', 'practice', 'tutorial'

Expected Answer:
No repeat terms: True
No repeat terms: False

Click for the answer



17. Write a python function to print out and remove every third items in the list a as provided until remove all the items in the list a.

The output is:

list_a = ['python', 'exercise', 'tutorial', 'practice', 'free', 'numpy', 'pandas']

Expected Answer:
tutorial
numpy
exercise
pandas
free
python
practice

Click for the answer

18. Write a python function to check whether the summation of any two number in list a and list b equal to a given number.

The output is:

list_a = [11, 6, 1, 4]
list_b = [21, 17, 4, 8]

Expected Answer:
True
False

Click for the answer



19. Write a python function to count the negative number in the list a and list b.

The output is:

list_a = [6, 2, 7, -8, -5]
list_b = [3, 2, 7, 9, -5, 1]

Expected Answer:
Count of negative number: [2]
Count of negative number: [1]

Click for the answer



20. Write a python function to count the number of same numbers with 3 given numbers in the list a and list b.

The output is:

list_a = [6, 6, 6]
list_b = [9, 7, 8]

Expected Answer:
The count of equal number is 3
The count of equal number is 0

Click for the answer



21. Write a python function to verify whether the student id are correct with 8 digits.

The output is:

student id 1 = 22365679
student id 2 = 1234567j

Expected Answer:
True
False

Click for the answer



                               


More Exercises:

Python String Exercises
Python List Exercises
Python Library Exercises
Python Sets Exercises
Python Array Exercises
Python Condition Statement Exercises
Python Lambda Exercises
Python Function Exercises
Python File Input Output Exercises
Python Tkinter Exercises


More Numpy Exercises:

Numpy String Exercises
Numpy Integer Exercises
Numpy Array Exercises
Numpy Data Analysis Exercises
Numpy Data Sorting Exercises


More Pandas Exercises:

Pandas Series Exercises


More Tutorials:

Python Installation - Linux (Ubuntu)
Python Installation - Mac OS
Integrated Development Environment - IDE
Python - Basic Variables
Python - Sequence Introduction
Python - Output Formatting
Python - Escape Character
Python - Type Conversion
Python - Numbers
Python – Arithmetic Operators
Python – Assignment Operators
Python – Comparison Operators
Python – Logical Operators
Python – Precedence and Associativity Operators
Python – Bytes Type and Usage
Python – Long & Raw Strings
Python – Concatenate Function
Python – Slice Function
Python – Length and Split Function
Python – Join and Count Function
Python – Find Function
Python – Index Function
Python – Alignment Function
Python – Startswith and Endswith Function
Python – String Case Conversion
Python – Remove Specified Character
Python – Encode and Decode Function
Python – dir and help Function
Python – Input Output Introduction
Python – Basic Operation
Python – Open Function
Python – Read Function
Python – Readline Function
Python – Write Function
Python – Close Function
Python – Seek and Tell Function
Python – Pickle Module
Python - File Input Module and Linecache Module
Python - Pathlib Module
Python - Pathlib Module
Python - os.path Module
Python - fnmatch Module
Python - Tuple Introduction
Python - List Introduction
Python - List Add Element
Python - List Delete Element
Python - List Modification Element
Python - List Find Element
Python - Dictionary Introduction
Python - Dictionary Basic Operation
Python - Dictionary Method Guide
Python - Set Collection
Python - Set Basic Operation
Python - Set Basic Method
Python - Frozenset Method
Python - If Condition I
Python - If Condition II
Python - While loop
Python - For loop
Python - Pass Statement
Python - Break Statement
Python - Zip Reverse Function
Python - Function Introduction
Python - Positional Parameters
Python - Key Arguments
Python - None and Return
Python - Variable Scope
Python - Local Function
Python - Closure Method
Python - Lamdba Expression