Python Programming

List of Assignments

Lecture 1: 15/02/2022

  1. What is the difference between HTML and Python?
  2. Name the founder of Python
  3. Enlist few programming languages
  4. Differenciate compiler and interpreter
  5. Name few intepreter based languages.
  6. Name few compilation based languages.
  7. What do you mean by open source software?
  8. Name at least five open source software/languages.
  9. Name at least five non-open source/commercial software/languages.
  10. List out 10 different editors and also mention for which purpose we can use them.

Lecture 2: 22/02/2022

  1. What do you mean by portabiity of software?
  2. List out few developer communities (e.g. Stackoverflow)
  3. Why python is called general purpose language?
  4. List out few services which use python.
  5. Enlist 5 programming languages with their use in specific domain

Lecture 3: 03/03/2022

Instruction: Entity enclosed in << >> indicates variable. Do not put static value there.

  • 1. Write a code to print : Hello “<<YOUR NAME>>”
  • 2. Write a code to get integer part of division operation.
    • Explanation: If a/b = 7.34, then your output should be 7
  • 3. Write code to get output in exactly following format:
    • 1 * 1 = 1
    • 2 * 2 = 4
    • 3 * 3 = 9
    • 4 * 4 = 16
  • 4. Assign your name and age in vairables called myname and myage. Your output should be exactly as follow:
    • My name is ‘<<YOUR NAME>>’, and I am “<<YOUR AGE>>” old
  • Print following pattern without using loop
    • * * * * *
    • * *
    • * *
    • * * * * *

Lecture 4: 08/03/2022

  1. Do study of google colab environment
  2. Understand funcationlity of Jyupyter Notebook editor on google colab
  3. Explore how files are managed on google drive by experimenting in google colab
  4. write a program that reads your name, your gender and your hobby. And it should display output as: Hi Folks, I am ‘YOUR NAME’, “YOUR GENDER” and I like YOUR HOBBY
  5. Write a program to demnostrate various operators such as, addition, subtraction, multiplication, division, integer division and exponent.
  6. Let a = 10, b = 20, c = 30. Use print( ) function such that your output should look like : a = ’20’, “b = 30”, c = “10”

Lecture 5: 17/03/2022

Note: Syntax <<VARIABLE>> represents the variable, don’t replace it by static string anywhere.

  1. Read your name in variable <<MYNAME>> and display output as follow: My name is “<<MYNAME>>” and length of my name is ‘<<LENGTH OF MYNAME>>’
  2. Print ‘<<MYNAME>>’ length of your name times: i,e, if MYNAME = ‘RAM’ then output should be ‘RAMRAMRAM’ (length of MYNAME is 3), if MYNAME = ‘ALEX’ then output shuold be ‘ALEXALEXALEXALEX’ (length of MYNAME is 4).
  3. Read your first name and last name in variables <<FNAME>> and <<LNAME>>. Display output as “I am <<FNAME >> <<LNAME>>”
  4. Write a code that demonstrate the use of single line and multiline comment
  5. Read ‘Python’ in variable <<LANGUAGE>>. Read ’70 billion’ in variable <<DEVELOPERS>>. Using key-value pair representation, format the output as follow: ‘Python’ is the most popular language across the globe. “70 billion” developers use ‘Python’ as their first choice language.

Lecture 6: 24/03/2022

Consider string S1 = “Hello Python, I fall in love with you”. Write a python code to get the following output for string S1.

  1. P
  2. Python
  3. Hello
  4. u
  5. you
  6. Print index of first character ‘w’
  7. Replace ‘Python’ with ‘HTML’ in S1
  8. Replace each occurance of ‘l’ with ‘L’ in S1

Lecture 7: 31/03/2022

Consider string S1 = “Hey Dude, i Love ICE HOCKEY”. Write a python code to get the following output for string S1.

  1. print all occurrences of ‘y’
  2. Output: Hey dude, i love ice hockey
  3. Output: Hey Dude, I Love Ice Hockey
  4. Reverse the string
  5. Print maximum and minimum character in S1
  6. Check S1 is starting with ‘Hi’
  7. Check if S1 is ending with ‘HOCKEY’
  8. Replace ‘ICE HOKECY’ in S1 with ‘SOCCER’

Lecture 8: 06/04/2022

1. Differentiate Tuple and list

Perform the following operations on Tuple: T = (11, 22.2, ‘a’, ‘Python’)

2. Print id of T

3. Repeat the tuple T thrice

4. Concate appropriate tuple to T, so that T will become (11, 22.2, ‘a’, ‘Python’, (1, 2), [‘Hello’, ‘Java’], (101, [‘A’, ‘B’, (‘x’, ‘y’, ‘z’)]))

Perform operations on T = (11, 22.2, ‘a’, ‘Python’, (1, 2), [‘Hello’, ‘Java’], (101, [‘A’, ‘B’, (‘x’, ‘y’, ‘z’)])) to get following outputs:

5. ‘Python’

6. [‘Hello’, ‘Java’]

7. [‘A’, ‘B’, (‘x’, ‘y’, ‘z’)]

8. ‘y’

9. 101

10. ‘A’, ‘B’

Lecture 9: 12/04/2022

1. Explain the difference between list and tuple (Hind: print id)

Take a list of your choice and demonstrate the following operations on that:

2. Repetition

3. Concatenation

4. Indexing

5. Update

6. Count occurrence of element

7. Find the length of the list

8. Check membership of an element in the list

9. Explain with an example: Append & Extend functions

10. Insert

11. Demonstrate with an example: Remove and del

Lecture 10: 19/04/2022

Consider the list L = [11, 22, 33, (‘a’, ‘b’, ‘c’), 55, [1, (2, 3)] ]

State the output for the following operations on list L:

Note: For all tasks, the output of current task shall be considered as input to next task

1. Find the length of the list L

2. Insert element 44 after 22

3. Which element is selected as an output on the second pop

4. Insert (111, 222, 333) as a single element at the end of the list

5. Insert (444, 555, 666) as individual elements of the list

6. Print every alternate element of the list in reverse order

7. Print the index of element (444, 555, 666)

8. Print the element 3 from L

9. How dictionary differs from a list?

10. Create a dictionary having name and age as key and appropriate values as their value

Lecture 11: 26/04/2022

No Assignment

Lecture 12: 03/05/2022

No Assignment

Lecture 03: 13/05/2022

No Assignment

Lecture 14: 30/06/2022

[1]. Read age of a person in a variable named << AGE >>, and print one of the following as an output based on the value of << AGE >> variable:

  • if AGE < 15: “You are Kid”
  • If 15 < AGE < 25: “You are Young”
  • If 25 < AGE < 55: “You are Adult”
  • if AGE > 55: “You are a senior citizen”

[2]. Read any color in variable << ColName >>.

  • If value of color is any of this : ColName = [‘red’, ‘green’, ‘blue’, ‘cyan’, ‘magenta’ ‘yellow’], then print ‘I LOVE THIS << ColName >> Color’,
  • Otherwise, print ‘Oppps…. You have a bad choice of colors! Get lost from here’

Lecture 15: 07/07/2022

[1]. Print first n numbers in reverse order using while loop.

Input: n = 8

Output: 8 7 6 5 4 3 2 1

[2]. Print squre and cube of first n numbers using while loop

Input: n = 5

Output:

  • Square of 1 is 1 and Cube of 1 is 1
  • Square of 2 is 4 and Cube of 2 is 8
  • Square of 3 is 9 and Cube of 3 is 27
  • Square of 4 is 16 and Cube of 4 is 64
  • Square of 5 is 25 and Cube of 5 is 125

[3]. Write a program to find factorial of n (denoted as n!).

n! = 1 * 2 * 3 * … * n

Input: 5

Output: 120

Input: 6

Output: 720