Python Programming Tutorial – Practice Questions

Reading Time: 7 minutes

First on the tutorial series for python programming language. Questions are based on the blogs I have published up until now.

Python Programming Introductions

Link to Python Programming Introductions Blog

  1. What are some popular industries to use python programming language?
  2. When was the python programming language created?
  3. What is a python interpreter?
  4. How can you start an interactive python session in your terminal?
  5. What is a python module?
  6. What is IDE?

Python VS Code Setup(optional)

Link to Python Programming Introductions Blog

  1. Download and Install VS Code on your computer
  2. Set Up python interpreter in your vs code.

Python Programming Data-Types

Link to Python Programming Introductions Blog

  1. What are several data types in python? Give some examples
  2. What does immutable mean in python? What are immutable data types in python?
  3. What are some features on the list data type?
  4. What are some features of dictionary data-type?

Python Buitin Functions

Link to Python Programming Introductions Blog

  1. Give examples of some of the commonly used built-in functions.
  2. What is the help function used for?
  3. Using help function, write usage and syntax for “int” function.
  4. How do you display values in your console?
  5. What is the length of this question?

Python Operators

Link to Python Programming Introductions Blog

  1. What are the types of operators?
  2. What type of operator is “==”?
  3. On your python terminal find out the square of 31434.

Python Numbers

Link to Python Programming Introductions Blog

  1. What are the types of numbers accepted in python?
  2. What do functions int() and float() do?
  3. Create a file named in your IDE? – hint: File>New File
  4. Create two new variables. Name them appropriately. Give those two variables values of 24 and 65.890 respectively.
  5. Print the variables.
  6. Print the type of these two variables.
  7. Don’t forget to add comments to explain to the readers.
  8. Calculate and Print the Area of a circle with a diameter of 124.


  • Google the formula
  • Determine how many variables are required, give them appropriate names.
  • Assign area to a variable
  • Print the area
  1. How would you find out if a number is odd or even? User 10 and 9, as an example. Hints: Even number is exactly divisible by 2 and odd number leaves a remainder.

Python Lists

Link to the Python List article.

Answer the following questions

  1. What is a python list?
  2. What are the few features of lists?
  3. How to create a list in python.
  4. What’s the difference between Insert and Append.

Coding Workouts

Coding Workouts

On your favorite IDE, create a file name Remember to use comments to explain to the readers what’s going on. And don’t use list comprehensions unless you’re told to in the question.

#1. Create a list named rainbow with all the colors of the rainbow in it.
#2. Create a list of your five school subjects, assign that list to an appropriate variable name.

#3. Print those two lists using appropriate strings.

#4. List of dry fruits
dry_fruits=['almond', 'pistachios', 'cashew', 'apricot', 'dates', 'walnuts', 'raisins']

# Questions
# 4.a. Print each item in the list (hints: use for loop)
# 4.b.  Print the length of the list.
# 4.c. What is the index of 'cashew' in the list?
# 4.d. Make a new copy of dry_fruits and assign it to dry_fruits_copy.
# 4.e. Reverse the new copy.
# 4.f. Print all the items except the first one.
# 4.g. You don't like the fruit dates, remove it from the copy list.
# 4.h. Add 'hazelnuts' to the list.

#5. Google the winning countries of football world cup from 1930 to 2018. Make a list of countries, regardless of repetition.

# Questions
# 5.a. Make sure all of the countries have initials capital. (through the code)
# 5.b. How many times have countries "Brazil" and "Germany" have won the cup.
# 5.c. Find the number of times each country on the list has won the cup.
# 5.d. Make a new list without repetition.
# 5.e. Sort the new list with the count from the original list.

# 6. Make a list of prime numbers less than 50.
  ## Hints ##
   ### Primary number logic, they are not divisible by any letters except by 1 and themselves.
  ### You can use for loop, range, if and else, and modulus operator for this workout. 
  ### Check out the blog where I make even and odd numbers for references.

# Questions
# 6.a. Create a copy of list and give it an appropriate name.
# 6.b. Perform floor division("//" floor operator) on each item in the copy.
# 6.c. Sort the original list by the result of floor division. (hint use key, attribute in sort().)

# 7. Copy the following code to your file and run it. Don't worry if you don't understand the code.

import numpy as np

rand_int = np.random.randint(200,10000, 50)

# 7.a. Print rand_int in your terminal. What do you see there? Anything different from the list.
# 7.b. Convert it into a python list.
# 7.c. Loop through the numbers in the list, create two lists, one with factors of 3 and another with even numbers.

# 8. Use only List Comprehension

# 8.a. Make a list consisting of alphabets in this sentence. "Thequickbrownfoxjumpsoverthelazydog".
# 8.b. Make a list of odd numbers less than 50.
# 8.c. Check if "radar" is a palindrome.
# 8.d. Add all the numbers from 20-40.
# Conver the items in the given list into binary numbers. hint use bin() for conversion.

numbers_lst=[5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0, 29.0, 31.0, 33.0, 35.0, 37.0, 39.0, 41.0, 43.0, 45.0, 47.0, 49.0, 51.0, 53.0, 55.0, 57.0, 59.0, 61.0, 63.0, 65.0, 67.0, 69.0, 71.0, 73.0, 75.0, 77.0, 79.0, 81.0, 83.0, 85.0, 87.0, 89.0, 91.0, 93.0, 95.0, 97.0, 99.0, 101.0, 103.0, 105.0, 107.0, 109.0, 111.0, 113.0, 115.0, 117.0, 119.0, 121.0, 123.0]

These are all the questions, based on the blog I’ve written. You can download the file with questions as zip from the download link below with the title Python List.

Python Strings

Link to Python Strings Tutorial

Link to python

  1. What is python string?

Coding Workouts

On your favorite IDE, create a file name Remember to use comments to explain to the readers what’s going on. And don’t use list comprehensions unless you’re told to in the question.

This is string exercise file. It is meant to serve as exercise file for 
python string tutorials @

# 1. Create a variable name and assign it your name

# 2. Use input() method to ask for Full Name.
# 2.a.Make sure the initials are capitalize.
# 2.b. Check if "James" is in the full name. Try lower and upper case, see what happens.

# 3. Assign new variable to this sentence. "Rita is hardworking girl."
# 3.a. Check if the sentence is past/present/future tense.
# 3.b. Convert to past tense.

# 4. Shouting
shouting = "ALL CAPS MEANS SHOUTING. IT's rude to write email in caps."

# 4.a. Make this sentence email friendly.
# 4.b, Get last sentence of the variable,assign it to new variable "useful_info".

# 5. Make an interactive program that asks user for values.
#  You'll be asking for the variables that are required to calculate simple interest.
#  final_amount = principal(1+interest_rate*time)
# 5.b. Make sure input has a informative text, while asking for keyboard input.
# Use format() method to print all variable.

# 6. Use above logic, to calculate area of equilateral triangle.
# Basic Metabolic Rate(BMR) can be calculated as:
# For women, it's
# BMR = 10 ⨉ weight (kg) + 6.25 ⨉ height (cm) – 5 ⨉ age (years) – 161
# For men, the formula is
# BMR = 10 ⨉ weight (kg) + 6.25 ⨉ height (cm) – 5 ⨉ age (years) + 5

# 6.a. Convert this formula to a proper equation recognized by python.
# 6.b Ask for all the variables to calculate the value.
# 6.c Ask for gender of user.
# 6.d Print the BMR value according to gender.
# 6.e. Make sure to use format() method to print BMR with two decimal points.

# 7 Str to list
vowel="  aeiou "
#7.a The vowel string is very confusing. Convert it to list with each char as an element.
#7.b Print the list it should be ['a','e','i','o','u']. If its not the same make it so.

# 8 
my_info= "I have a degree in IT engineering."

# 8.a Extract IT from the string.
# 8.b  Replace IT with computer.

# 9  My Birthday
brith_date = "16-06-1993"

# 9.a Make changes to string. When you're done birth date, should be "16, June, 1993".
# Hints use some combo of split, replace, join 

Python Dictionary

Link to Python Dictionary Blog

  1. What is python dictionary?
  2. Is dictionary a Mutable object?
  3. What key features of dictionary distinguishes itself from python list object?

On your favorite IDE, create a file name Remember to use comments to explain to the readers what’s going on. And don’t use list comprehensions unless you’re told to in the question.

This is dictionary exercise file. It is meant to serve as exercise file for 
python dictionary tutorials @

# 1. Create a empty dictionary name personal_info
# 1.a. Fill in your name, age, location, relationship_status information with appropriate key and values
# 1.b. Loop Through each items and print values.

# 2.
dict_1 = {'one': 1, 'three': 3}

dict_2 = {'two': 2, 'four': 4}

# 2.a. Merge two dictionaries into a new dictionary, assign it it a variable named alpha_num
# 2.b. Sort the new dictionary by values on descending order.
# 2.c. Find the minimum values of the new dictionary.(Rules : Your coding should work on all arbitrary dictionary, so, don't access smallest value like dict['one'])

# 3. Write a simple script to find if a key exists in a dictionary. The script should print value if the key exists.
# **HINT: Combine if, in and keys() method. **

# 4. Write a script to create dictionary, that has list of even, odd and prime numbers from range 1 to 100.
# For instance, dictionary should look like this:
sample_dict = {
    'even': [2, 4, 6],
    'odd': [3, 5, 9],
    'prime': [3, 5, 7, 11]
# **HINT:**
# 1. Create three empty list even,odd, prime.
#  2. use for loop for given range,
# 3. modulus (%) and if to check even, odd or prime number logic
# 4. Append relevant values to list
# 5. Add relevant list to with appropriate keys.

# 5. From the dictionary created in question 4.
# 5.a. Add all the even numbers.
# 5.b. Subtract all the odd numbers from 200.
# 5.c. Divide all the prime numbers by 0.65

# 6.

movie_dets = {
    1: {'name': 'Shadow in the clouds', 'release_date': 'Jan 7, 2021'},

    2: {'name': 'Pieces Of a Woman', 'release_date': 'Jan 8, 2021'},

    3: {'name': 'Horizon Line', 'release_date': 'Jan 12, 2021'},

    4: {'name': 'Redemption Day', 'release_date': 'Jan 12, 2021'},

    5: {'name': 'Locked Down', 'release_date': 'Jan 14, 2021'},

    6: {'name': 'The Marksman', 'release_date': 'Jan 15, 2021'},

    7: {'name': 'The Dig', 'release_date': 'Jan 15, 2021'},

    8: {'name': 'Stallone: Frank, That Is ', 'release_date': 'Jan 19, 2021'},

    9: {'name': 'The Human Factor', 'release_date': 'Jan 22, 2021'},


# 6.a. Print all the movie names in the list.
# 6.b. Print only the Movies released on first half of January.
# 6.c. Create a duplicate dictionary and add movie "Wrong Turn" which was released on Jan 26,2021. Add it to the 10th key.
#6.d. What is the length of new dictionary? Compare the length of odd dictionary. Should it same or not? 

Download Exercises

This is a live question blog, I will keep on updating this blog for new advanced problems as my tutorial progresses. Please do like and subscribe for regular news on updates.

Leave a Reply

%d bloggers like this: