## List of Assignments

Assignment – 01:

1. What is the difference between HTML and Python?
2. Name the founder of Python
3. Enlist a few programming languages
4. Differentiate compiler and interpreter
5. Name a few interpreter-based languages.
6. Name a 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 10 different editors and also mention for which purpose we can use them.

Assignment – 02:

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

Assignment – 03:

. Consider variables A = 8 and B = 6.

Write a program to demonstrate various arithmetic operators

. Consider x = 30 and y = 30

Write a program to demonstrate various comparison operators

Assignment – 04:

. Find a binary number of the following decimal (Using pen and paper): < 45, 127, 513, 1023, 2049 >

. Convert the following binary number to decimal (Using pen and paper): < 1000101, 1110101, 1111, 10101010111 >

. Write a program to demonstrate various logical and bitwise operators

. WAP to demonstrate the use of membership operators

Assignment – 05:

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

. Write a code to print: Hello “<<YOUR NAME>>”

. Write a code to get the integer part of a division operation.

Explanation: If a/b = 7.34, then your output should be 7

. Write code to get output in exactly the following format:

1 * 1 = 1

2 * 2 = 4

3 * 3 = 9

4 * 4 = 16

. Assign your name and age in variables called myname and myage. Your output should be exactly as follow:

. Print the following pattern without using a loop

* * * * *
*       *
*       *
*       *
* * * * *

Assignment – 06:

. Do a study of the google colab environment

. Understand the functionality of the Jyupyter Notebook editor on google colab

. Explore how files are managed on google drive by experimenting with google collab

. Write a program to demonstrate various operators such as addition, subtraction, multiplication, division, integer division and exponent.

. Let a = 10, b = 20, c = 30. Use print( ) function such that your output should look like : a = ’20’, “b = 30”, c = “10”

Assignment – 07:

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

. Read your name in variable <<MYNAME>> and display output as follow: My name is “<<MYNAME>>” and length of my name is ‘<<LENGTH OF MYNAME>>’

. Print ‘<<MYNAME>>’ length of your name times: i,e, if MYNAME = ‘RAM’ then the output should be ‘RAMRAMRAM’ (length of MYNAME is 3), if MYNAME = ‘ALEX’ then the output should be ‘ALEXALEXALEXALEX’ (length of MYNAME is 4).

. Read your first name and last name in variables <<FNAME>> and <<LNAME>>. Display output as “I am <<FNAME >> <<LNAME>>”

. Write a code that demonstrates the use of single-line and multiline comment

. 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.

Assignment – 08:

. 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 occurrence of ‘l’ with ‘L’ in S1

. Consider the string S1 = ‘Hello How Are You?’

• Find the index of character ‘o’
• Replace ‘You’ with ‘Dogs’
• Slice string to print the following:
• eel
• Are
• Hello How
• Are You

. Reverse the string

. Print the same string 10 times by repetition.

. Concate ‘I am Fine’ with S1

Assignment – 09:

. 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 characters 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’

Assignment – 10:

. What do you mean by mutable and immutable objects?

. State the advantages of a tuple over a string

. Differentiate: Tuple vs. List

. Given the Tuple: T = ((1, 2, (‘Hello’, 11, 12, “Python”)), 21, 22, [31, 32, (“Zain”, 13, “Sania”, 12), “World], 41, 42). Perform operations to get the following outputs:

• Find the length of T and match it with your understanding
• Output: (1, 2, (‘Hello’, 11, 12, “Python”))
• Output: 11
• Output: P
• Output: 21, 22
• Output: Zain
• Output: Sania
• Output: S
• Output: W
• Output: 12

Assignment – 11:

. Differentiate Tuple and list

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

• Print id of T
• Repeat the tuple T thrice
• 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:

• ‘Python’
• [‘Hello’, ‘Java’]
• [‘A’, ‘B’, (‘x’, ‘y’, ‘z’)]
• ‘y’
• 101
• ‘A’, ‘B’

Assignment – 12:

. Consider the list L = [1, (2, 3), [4, 5, (6, 7, [8, 9, 10], 11, 12), 13], (14, ‘Hello’, [15, “Python”, “HTML”]) ]

Write python code to get the following output form list L:

1. [8, 9, 10]
2. Python
3. M
4. 5
5. 8, 9

. Consider the same list L and write a python code to get the following output: (Take care of exact formatting)

1. The First element of the list is 1, and the last element of the list is “HTML”
2. The First element is 1, the second element is (2, 3), the third element is [4, 5, (6, 7, [8, 9, 10], 11, 12), 13] and the last element is (14, ‘Hello’, [15, “Python”, “HTML”])
3. I like ‘Python’ over ‘HTML’ (Note: Python and HTML should be fetched from L, do not just type them in the print function)
4. Replace HTML with Java and print the following string as an output: Hello ‘Python’, I am ‘java’, How are you?

. Consider the same List L and perform the following operations on it:

1. Replace ‘Hello” with ‘Hi’
2. Count occurrence of ‘o’
3. Fetch and reverse the word HTML
4. Can we find Max, Min and the sum of L? Why?

Assignment – 13:

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

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

• Repetition
• Concatenation
• Indexing
• Update
• Count the occurrence of element
• Find the length of the list
• Check membership of an element in the list
• Explain with an example: Append & Extend functions
• Insert
• Demonstrate with an example: Remove and del

Assignment – 14:

. Consider the list L = [30, 10, 20]. Your output should be:

• In L, the maximum number is 30, the minimum number is 10 and the average is 20. The length of L is 3.

. Create sets as follow: A = Set of even numbers less than 12, B = Set of perfect squares less than 30. Perform the following operations on two sets:

• Union of sets
• Intersection of sets
• Difference of sets

. Create the dictionary in different ways using the following keys and corresponding values as follows:

Keys = {1, 2, 3, 4, 5, 2, 3}

Values = {‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’}

. Perform pop operation on the previous dictionary to remove element G.

. Add (7, ‘Seven’) key-value pair to the dictionary used in the previous example.

Assignment – 15:

. 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 the current task shall be considered as input to the next task

• Find the length of the list L
• Insert element 44 after 22
• Which element is selected as an output on the second pop
• Insert (111, 222, 333) as a single element at the end of the list
• Insert (444, 555, 666) as individual elements of the list
• Print every alternate element of the list in reverse order
• Print the index of element (444, 555, 666)
• Print element 3 from L
• How dictionary differs from a list?
• Create a dictionary having name and age as key and appropriate values as their value

Assignment – 16:

. Read the 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 an Adult”
• if AGE > 55: “You are a senior citizen”

. Read any color in variable << ColName >>.

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

Assignment – 17:

. Print odd numbers between 1 to 20 using a while loop

. Print even numbers between 40 to 50 using a while loop (both numbers included)

. Print the following output using the while loop:

*
* *
* * *
* * * *

Assignment – 18:

. Compare the digits of two numbers and check if both numbers are the same or not

. Add a square of digits of the number and print the sum

. Print the number, its square and its cube for 1 to 10 numbers:

. Write a program using a while loop to count elements greater than 50 from the given list

. Write a program using while loop to find perfect square numbers less than 10 from the given list

. Write a program using a while loop to print the list in reverse order

Assignment – 19:

. Write a program to implement the following patterns using a while loop:

1 2 3
2 3
3
1 2 3
1 2
1
1
2 1
3 2 1

Assignment – 20:

. Write a program to implement the following patterns using a while loop:

1 2 3
2 3
3
1 2 3
1 2
1
  1
2 1
3 2 1

Assignment – 21:

. Write a program to implement the following patterns using a while loop:

3 2 1
3 2
3

3 2 1
3 2
3

3 2 1
2 1
1

Assignment – 22:

. Print the first n numbers in reverse order using a while loop.

Input: n = 8

Output: 8 7 6 5 4 3 2 1

. Print square 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

. Write a program to find the factorial of n (denoted as n!).

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

Input: 5

Output: 120

Input: 6

Output: 720

Assignment – 23:

. Print numbers between 1 to 100 which are multiple of 5 using for loop

. Print even numbers between 70 t0 90 in reverse order using for loop

. Print numbers between 51 to 78 which are divisible by 4 using for loop

Assignment – 24:

. Print Armstrong Number between 1 to 100 (Hint: Use while and for loop)

. Print the first three Armstrong numbers between 1 to 100 (Hint: Use while and for loop)

. Initialize the list of numbers. Cout and print the number of positive, negative and zero elements in the given list using for loop

Assignment – 25:

. Write a function reverseList(L) to print the list in reverse order

. Write a function MulTable(m, n) which prints the multiplication table of m up to n

Assignment – 26:

. Implement lambda function to print if a given number is positive or negative

. Implement lambda function to print if the first number is larger or smaller than the second number

. Using map and lambda function, multiply each element of the list by 2

. Create a list of fruits. Using map and lambda function, convert all fruit names to upper case.

. Create a list of temperature values. Using map and lambda function, convert the temperature in ferenhite.

Assignment – 27:

. Compute the sum of the first N numbers using recursion

. Print first N numbers in reverse order using Recursion

. Add digits of a number using Recursion

. Reverse the number using recursion

. Reverse the string using recursion