You are on page 1of 1

PHY105: Assignment 1

Instructor: Tobias Toll


July 26
Submit programs files (soft copies) by Friday July 28,
via email to tobias.toll@snu.edu.in, and rs190@snu.edu.in
Create programs using Python 3.x using any editor e.g. Spyder.
Name your files thus: (your-name)_assignment(number)_prob(number).py.
Example: Sushmita will save her assignment 1, problem 2, as
Sushmita_assigment1_prob2.py

Submit the assignments over email to Dwaipaian: dc167@snu.edu.in and tobias.toll@snu.edu.in

1. As we have seen in class, a list is a mutable object, meaning that we can change its elements and
even the number of elements in the list. A tuple is similar to a list, but it is immutable, meaning that
once it has been defined it cannot be changed. A tuple is defined with round brackets () instead of the
square brackets [] of the list. Can you think of a reason for why we want objects to be immutable?
Write a program which uses a 'tuple' to create a data base of your name, date of birth, and place of
birth, and then prints them one by one. (Feel free to make things up.)
2. Write a program which determines whether a string is shorter, longer or precisely 10 characters using
if statements. Let the program ask for user input for the string.
3. In the list [-1.0, 0.5, -0.5, 1.0] add 0.0 to the beginning and -2.0 to the end. Find the
index (i.e. its number in the list) of -0.5, reverse the list and remove all numbers which are less than
one. Hint: do dir(list) to find out about the functions available to list. The function comes after your
list: your_list.function(arguments). Also, have a look at this page:
https://www.tutorialspoint.com/python/python_lists.htm

You might also like