X
Online Degree

Python Programming Lab

By Dr. Shaveta Bhatia   |   Manav Rachna International Institute of Research and Studies

Learners enrolled: 7

SUMMARY

Course Status : Ongoing
Course Type : Core
Duration :
Start Date :
End Date :
Exam Date :
Category :
Level : Postgraduate

COURSE LAYOUT

Topics to be covered: Installation and Working with Python, Setting up path & Running Python Scripts, Variables & Data Types, Keywords,  Input-Output,  Indentation


  1. Write a Python program to display the current date and time.

  2. Write a Python program which accepts the radius of a circle from the user and compute the area

  3. Write a Python program which accepts the user's first and last name and print them in reverse order with a space between them.

  4. Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn

  5. Write a Python program to print the calendar of a given month and year.

  6. Write a Python program to calculate number of days between two dates.
    Sample dates : (2014, 7, 2), (2014, 7, 11)
    Expected output : 9 days 

  7. Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.

  8. Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2?

Topics to be covered: Python basic Operators, Declaring and using Numeric data types: int, float complex, Using string data type and string operations, Defining list and list slicing, Use of Tuple data type, Introduction to Dictionaries, Understanding string inbuilt methods,  List manipulation using inbuilt methods, Dictionary manipulation, Programming using string, list and dictionary in build functions


  1. Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers.

  2. Write a Python program to calculate the sum of three given numbers, if the values are equal then return thrice of their sum.

  3. Write a Python program to test whether a passed letter is a vowel or not

  4. Take a list, say for example this one:

a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

       and write a program that prints out all the elements of the list that are less than 5.

Extras:

  1. Instead of printing the elements one by one, make a new list that has all the elements less than 5 from this list in it and print out this new list.

  2. Write this in one line of Python.

  3. Ask the user for a number and return a list that contains only elements from the original list a that are smaller than that number given by the user.

  1. Create a program that asks the user for a number and then prints out a list of all the divisors of that number. (If you don’t know what a divisor is, it is a number that divides evenly into another number. For example, 13 is a divisor of 26 because 26 / 13 has no remainder.)

  2. Take two lists, say for example these two:

  a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

  b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

and write a program that returns a list that contains only the elements that are common between the lists (without duplicates). Make sure your program works on two lists of different sizes.

  1. Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)

  2. Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it. 


Topics to be covered: Conditional blocks using if, else and Nested If-else, Simple For loops in python, For loop using ranges, string, list and dictionaries, Use of while loops in python, Loop manipulation using pass, continue, break and else, Programming using Python conditional and loops block


  1. Generate a random number between 1 and 9 (including 1 and 9). Ask the user to guess the number, then tell them whether they guessed too low, too high, or exactly right. (Hint: remember to use the user input lessons from the very first exercise)

  2. Ask the user for a number and determine whether the number is prime or not. (For those who have forgotten, a prime number is a number that has no divisors.).

  3. Write a program (function!) that takes a list and returns a new list that contains all the elements of the first list minus all the duplicates.

  4. Write a function that takes an ordered list of numbers (a list where the elements are in order from smallest to largest) and another number. The function decides whether or not the given number is inside the list and returns (then prints) an appropriate boolean.

  5. Implement a function that takes as input three variables, and returns the largest of the three. Do this without using the Python max() function!

  6. Make a mini project based on concepts above list of practical.  Suggested mini projects are:

  1. Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main method.

  2. Make a two-player Rock-Paper-Scissors game. (Hint: Ask for player plays (using input), compare them, print out a message of congratulations to the winner, and ask if the players want to start a new game)

      Remember the rules:

  • Rock beats scissors

  • Scissors beats paper

  • Paper beats rock

BOOKS AND REFERENCES

Allen B . Downey, Think Python, 2016,  How to Think Like a Computer Scientist, Shroff/O‘Reilly Publishers

2. Guido van Rossum and Fred L. Drake Jr, 2011, An Introduction to Python – Revised and updated for Python 3.2, Network Theory Ltd.

3. Robert Sedge wick, Kevin Wayne, Robert Dondero, 2015, Introduction to Programming in Python: An Inter-disciplinary Approach, Pearson India Education Services Pvt. Ltd.

4. Python Programming using problem solving approach, 2019, Reema Thareja, Oxford University Press


INSTRUCTOR BIO

Dr. Shaveta Bhatia

Manav Rachna International Institute of Research and Studies
  • Deputy Director, Centre for Distance & Online Education

  • Manav Rachna International Institute of Research & Studies


   Qualification: Ph.D, Computer Science, MCA

    Experience : 20 Years


Area of Interest: Mobile Computing, Web Application Development, Database Management System, Networking

Published more than 40 papers in International/ National Journals conferences, 2 books published  & Member of ACM,CSI Editor and Reviewer of various renowned journals. 


COURSE CERTIFICATE

Ministry of Education logo Swayam logo

FOLLOW US