Python Exercise Lists

Python List Exercises

1. Write a python program to select the highest number from the list of number as in the output below.

The output is:

number_list = [22, 5, 76, 100, 12.3, 9]
Expected Answer: The highest number in the number_list is: 100

Click for the answer



2. Write a python program to select the lowest number from the list of number as in the output below.

The output is:

number_list = [22, 5, 76, 100, 12.3, 9]
Expected Answer: The lowest number in the number_list is: 5

Click for the answer



3. Write a python program to arrange the list of number as in the output below in increasing order.

The output is:

number_list = [22, 5, 76, 100, 12.3, 9]
Expected Answer: The number_list arranged in increasing order: [5, 9, 12.3, 22, 76, 100]

Click for the answer



4. Write a python program to arrange the list of number as in the output below in decreasing order.

The output is:

number_list = [22, 5, 76, 100, 12.3, 9]
Expected Answer: The number_list arranged in increasing order: [100, 76, 22, 12.3, 9, 5]

Click for the answer



5. Write a python program to remove all the odd numbers from the number_list variable as in the output below.

The output is:

number_list = [22, 5, 76, 100, 12.3, 9, 88, 7, 13, 57]
Expected Answer: The remaining even numbers in the number_list are: [22, 76, 100, 88]

Click for the answer



6. Write a python program to switch the sequence of each word in the noun_list as in the output below.

The output is:

noun_list = ['Python', 'Exercises', 'Free', 'Answer', 'Tutorials', 'Numpy']
Expected Answer: The new noun list after changing sequence: [Different from original noun_list]

Click for the answer



7. Write a python program to switch a list of character_a as in the output below into a string.

The output is:

character_a = ['p', 'y', 't', 'h', 'o', 'n']
Expected Answer:Changing from a list of character ['p', 'y', 't', 'h', 'o', 'n'] into a string: python

Click for the answer



8. Write a python program to access the index of noun_list as in the output below. Note that the loop method is needed to assist in getting answer.

The output is:

noun_list = ['Python', 'Exercises', 'Free', 'Answer', 'Tutorials', 'Numpy']
Expected Answer:
0 Python
1 Exercises
2 Free
3 Answer
4 Tutorials
5 Numpy

Click for the answer



9. Write a python program to establish all the possible permutations of a given list in the following output.

The output is:

list = [7, 8, 9]
Expected Answer:
[(7, 8, 9), (7, 9, 8), (8, 7, 9), (8, 9, 7), (9, 7, 8), (9, 8, 7)]

Click for the answer



10. Write a python program to obtain the deviation between the list_a and list_b as given in the following output.

The output is:

list_a = [22, 52, 79, 55, 31, 90, 67, 54, 87]
list_b = [31, 52]
Expected Answer:
The deviation between the list_a and list_b are: [67, 79, 54, 55, 22, 87, 90]

Click for the answer



11. Write a python program to join a list of fruits as provided in the following output with a symbol '-' in between fruits.

The output is:

fruits = ['Apple', 'Grapes', 'Berry', 'Mango']

Expected Answer:
All fruits are: Apple-Grapes-Berry-Mango

Click for the answer



12. Write a python program to check whether all the numbers in the list a actually greater than certain number.

The output is:

list_a = [5,6,9,10,12,15]
number: 4 and 9

Expected Answer:
All numbers in the list greater than 4: True
All numbers in the list greater than 9: False

Click for the answer



13. Write a python program randomly generate a list of eight odd numbers in the range of 1 to 50.

The output is:

Expected Answer:
[17, 21, 23, 45, 27, 35, 41, 31]

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