List of Assignments
Assignment – 01:
- What is the difference between HTML and Python?
- Name the founder of Python
- Enlist a few programming languages
- Differentiate compiler and interpreter
- Name a few interpreter-based languages.
- Name a few compilation-based languages.
- What do you mean by open-source software?
- Name at least five open-source software/languages.
- Name at least five non-open source/commercial software/languages.
- List 10 different editors and also mention for which purpose we can use them.
Assignment – 02:
- What do you mean by the portability of software?
- List out a few developer communities (e.g. Stackoverflow)
- Why python is called a general-purpose language?
- List out a few services which use python.
- Enlist 5 programming languages with their use in a specific domain
Assignment – 03:
[1]. Consider variables A = 8 and B = 6.
Write a program to demonstrate various arithmetic operators
[2]. Consider x = 30 and y = 30
Write a program to demonstrate various comparison operators
Assignment – 04:
[1]. Find a binary number of the following decimal (Using pen and paper): < 45, 127, 513, 1023, 2049 >
[2]. Convert the following binary number to decimal (Using pen and paper): < 1000101, 1110101, 1111, 10101010111 >
[3]. Write a program to demonstrate various logical and bitwise operators
[4]. WAP to demonstrate the use of membership operators
Assignment – 05:
Instruction: Entity enclosed in << >> indicates variable. Do not put the static value there.
[1]. Write a code to print: Hello “<<YOUR NAME>>”
[2]. Write a code to get the integer part of a division operation.
Explanation: If a/b = 7.34, then your output should be 7
[3]. Write code to get output in exactly the following format:
1 * 1 = 1
2 * 2 = 4
3 * 3 = 9
4 * 4 = 16
[4]. Assign your name and age in variables called myname and myage. Your output should be exactly as follow:
My name is ‘<<YOUR NAME>>’, and I am “<<YOUR AGE>>” old
[5]. Print the following pattern without using a loop
* * * * *
* *
* *
* *
* * * * *
Assignment – 06:
[1]. Do a study of the google colab environment
[2]. Understand the functionality of the Jyupyter Notebook editor on google colab
[3]. Explore how files are managed on google drive by experimenting with google collab
[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 demonstrate 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”
Assignment – 07:
Note: Syntax <<VARIABLE>> represents the variable, don’t replace it with a 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 the output should be ‘RAMRAMRAM’ (length of MYNAME is 3), if MYNAME = ‘ALEX’ then the output should 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 demonstrates 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.
Assignment – 08:
[1]. Consider string S1 = “Hello Python, I fall in love with you”. Write a python code to get the following output for string S1.
- P
- Python
- Hello
- u
- you
- Print index of first character ‘w’
- Replace ‘Python’ with ‘HTML’ in S1
- Replace each occurrence of ‘l’ with ‘L’ in S1
[2]. 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
[3]. Reverse the string
[4]. Print the same string 10 times by repetition.
[5]. Concate ‘I am Fine’ with S1
Assignment – 09:
[1]. Consider string S1 = “Hey Dude, I Love ICE HOCKEY”. Write a python code to get the following output for string S1.
- print all occurrences of ‘y’
- Output: Hey dude, I love ice hockey
- Output: Hey Dude, I Love Ice Hockey
- Reverse the string
- Print maximum and minimum characters in S1
- Check S1 is starting with ‘Hi’
- Check if S1 is ending with ‘HOCKEY’
- Replace ‘ICE HOKECY’ in S1 with ‘SOCCER’
Assignment – 10:
[1]. What do you mean by mutable and immutable objects?
[2]. State the advantages of a tuple over a string
[3]. Differentiate: Tuple vs. List
[4]. 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:
[1]. Differentiate Tuple and list
[2]. 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’)]))
[3]. 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:
[1]. 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:
- [8, 9, 10]
- Python
- M
- 5
- 8, 9
[2]. Consider the same list L and write a python code to get the following output: (Take care of exact formatting)
- The First element of the list is 1, and the last element of the list is “HTML”
- 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”])
- I like ‘Python’ over ‘HTML’ (Note: Python and HTML should be fetched from L, do not just type them in the print function)
- Replace HTML with Java and print the following string as an output: Hello ‘Python’, I am ‘java’, How are you?
[3]. Consider the same List L and perform the following operations on it:
- Replace ‘Hello” with ‘Hi’
- Count occurrence of ‘o’
- Fetch and reverse the word HTML
- Can we find Max, Min and the sum of L? Why?
Assignment – 13:
[1]. Explain the difference between a list and a tuple (Hind: print id)
[2]. 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:
[1]. 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.
[2]. 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
[3]. 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’}
[4]. Perform pop operation on the previous dictionary to remove element G.
[5]. Add (7, ‘Seven’) key-value pair to the dictionary used in the previous example.
Assignment – 15:
[1]. 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:
[1]. 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”
[2]. 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:
[1]. Print odd numbers between 1 to 20 using a while loop
[2]. Print even numbers between 40 to 50 using a while loop (both numbers included)
[3]. Print the following output using the while loop:
*
* *
* * *
* * * *
Assignment – 18:
[1]. Compare the digits of two numbers and check if both numbers are the same or not
[2]. Add a square of digits of the number and print the sum
[3]. Print the number, its square and its cube for 1 to 10 numbers:
[4]. Write a program using a while loop to count elements greater than 50 from the given list
[5]. Write a program using while loop to find perfect square numbers less than 10 from the given list
[6]. Write a program using a while loop to print the list in reverse order
Assignment – 19:
[1]. 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:
[1]. 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:
[1]. 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:
[1]. Print the first n numbers in reverse order using a while loop.
Input: n = 8
Output: 8 7 6 5 4 3 2 1
[2]. 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
[3]. 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:
[1]. Print numbers between 1 to 100 which are multiple of 5 using for loop
[2]. Print even numbers between 70 t0 90 in reverse order using for loop
[3]. Print numbers between 51 to 78 which are divisible by 4 using for loop
Assignment – 24:
[1]. Print Armstrong Number between 1 to 100 (Hint: Use while and for loop)
[2]. Print the first three Armstrong numbers between 1 to 100 (Hint: Use while and for loop)
[3]. 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:
[1]. Write a function reverseList(L) to print the list in reverse order
[2]. Write a function MulTable(m, n) which prints the multiplication table of m up to n
Assignment – 26:
[1]. Implement lambda function to print if a given number is positive or negative
[2]. Implement lambda function to print if the first number is larger or smaller than the second number
[3]. Using map and lambda function, multiply each element of the list by 2
[4]. Create a list of fruits. Using map and lambda function, convert all fruit names to upper case.
[5]. Create a list of temperature values. Using map and lambda function, convert the temperature in ferenhite.
Assignment – 27:
[1]. Compute the sum of the first N numbers using recursion
[2]. Print first N numbers in reverse order using Recursion
[3]. Add digits of a number using Recursion
[4]. Reverse the number using recursion
[5]. Reverse the string using recursion