Practice Problems

Python Made Easy: Science and Math Edition

Sep-Dec 2025 batch, Vikrant Patil

Date: 15 Nov 2025

Click here for All Notes

© Vikrant Patil

one-two liners

  1. list indexing, get a item from a list
  2. list slicing, get multiple items from a list
  3. how do you get last item from list?
  4. drop first 3 items from a list using list slicing
  5. take first 4 items from a list using list slicing
  6. reverse the list using list slicing
  7. make list of words from a sentence
  8. make a statement given a list of words. statement is just a text where in words are separated by space. it need not have a meaning.
  9. take an empty list and add 5 items to it one by one.
  10. take two lists and concatenate them
  11. take a string (text) and make it 5 time repeating text.
  12. check if “hello” is there in a text
  13. how will you check if 2 is present in a list [1, 3, 4, 5, 6, 7]

functions and loops

  1. Write a function timebomb which prints “tick” every second and after n seconds prints “BOOOM!!!!” n is integer argument o function. Make use time module. e.g. time.sleep(2) function waits for 2 seconds.

  2. Write a function take which will create a a list of first n items from given list.

  3. Write a function to generate a list n random numbers. Every random number should be a number between 0 to 1. make use of random.random function to generate random number.

  4. Write a function average which will find out average value of a number from given list. it takes list of numbers as argument.

  5. Write a function find_words_of_len to find words of given length from given list.

    >>> find_words_of_len(words, 3)
    ['one', 'two', 'six']
  6. Write a function unique which will remove duplicates from a list.

  7. List of urls is given. Some urls are from same domain, some are from different. Find unique domain names used in the urls. urls = ['www.abrakadabra.com/dccEcB/EGdd', 'www.abrakadabra.com/gADFeD/bcAF', 'www.abra.com/AGadbb/eagE', 'www.dabra.com/cffdfD/FCAD', 'www.abra.com/GFGaBE/dcfc', 'www.abra.com/gaFegG/Bdaf', 'www.abrakadabra.com/aGabaf/EEfa', 'www.dabra.com/ceEgFD/bGgc', 'www.dabra.com/bDEffC/bcEA']

  8. print 5 times hello

  9. find sum of first 59 natural numbers

  10. write a function to compute simple interest given principle, rate and duration

  11. Write a function voice_of_wild which takes an argument of species name and prints the word associated with that species’s voice. Make use use of conditions to do this. Your function should support following species and their voice as given below

  ===========   ====================================
  species          voice                              
  ===========   ====================================
  bird            chirp      
  bat             echolocation
  cat             meow
  dog             bark
  duck            quack
  any other       Not supported
  ===========   ==================================== 
  1. Write a function factorial which will find factorial of a given number.

scripts

  1. Write a python script add.py which will take tow number from command line and print the addition
  2. Write a python script chaos.py which prints first 10 iterations of x which is computed using follwing logic. To start with some value of x is given by user (from command line arguments). After that for each iteration new value of x is generated using the equation x = 3.9 * x * (1 - x) after computing new value of x print it to screen. See what happens to value of x at 10 itertion for different starting values of x i.e. 0.24, 0.25, 0.26, 0.3 etc.