Practice Problems
Python Made Easy: Science and Math Edition
Sep-Dec 2025 batch, Vikrant Patil
Date: 15 Nov 2025
© Vikrant Patil
one-two liners
- list indexing, get a item from a list
- list slicing, get multiple items from a list
- how do you get last item from list?
- drop first 3 items from a list using list slicing
- take first 4 items from a list using list slicing
- reverse the list using list slicing
- make list of words from a sentence
- 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.
- take an empty list and add 5 items to it one by one.
- take two lists and concatenate them
- take a string (text) and make it 5 time repeating text.
- check if “hello” is there in a text
- how will you check if 2 is present in a list [1, 3, 4, 5, 6, 7]
functions and loops
Write a function
timebombwhich 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.Write a function
takewhich will create a a list of firstnitems from given list.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.
Write a function
averagewhich will find out average value of a number from given list. it takes list of numbers as argument.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']Write a function unique which will remove duplicates from a list.
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']print 5 times hello
find sum of first 59 natural numbers
write a function to compute simple interest given principle, rate and duration
Write a function
voice_of_wildwhich 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
=========== ====================================
- Write a function
factorialwhich will find factorial of a given number.
scripts
- Write a python script
add.pywhich will take tow number from command line and print the addition - Write a python script
chaos.pywhich prints first 10 iterations ofxwhich is computed using follwing logic. To start with some value ofxis given by user (from command line arguments). After that for each iteration new value ofxis generated using the equationx = 3.9 * x * (1 - x)after computing new value ofxprint it to screen. See what happens to value ofxat 10 itertion for different starting values ofxi.e. 0.24, 0.25, 0.26, 0.3 etc.