**PART A – List of problems for which student should develop program and execute in the Laboratory**

**Write a python program to find the best of two test average marks out of three test’s marks accepted from the user**‘

**Source Code **:

```
mark1 = int (input("Enter the marks in the first test:"))
mark2 = int (input("Enter the marks in second test: "))
mark3 = int (input("Enter the marks in third test: "))
if (mark1 > mark2):
if (mark2 > mark3):
total_marks = mark1 + mark2
else:
total_marks = mark1 + mark3
elif (mark1 > mark3):
total_marks = mark1 + mark2
else:
total_marks = mark2 + mark3
Average_marks = total_marks / 2
print ("The average of the best two test marks is:",Average_marks)
```

Output :

```
Enter the marks in the first test:18
Enter the marks in second test: 19
Enter the marks in third test: 24
The average of the best two test marks is: 21.5
```

2. **Develop a Python program to check whether a given number is palindrome or not and also count the number of occurrences of each digit in the input number.**

Source Code :

```
num = int(input("Enter a number: "))
temp1 = num
reverse = 0
while temp1 > 0:
remainder = temp1 % 10
reverse = (reverse * 10) + remainder
temp1 = temp1 // 10
if num == reverse:
print('The Entered Number %d is Palindrome'%(num))
else:
print("The Entered Number %d is Not a Palindrome"%(num))
print("Digit\tFrequency")
for i in range(0,10):
count=0
temp2=num
while temp2>0:
digit=temp2%10
if digit==i:
count=count+1
temp2=temp2//10
if count>0:
print(i,"\t",count)
```

Output:

```
Enter a number: 789923
The Entered Number 789923 is Not a Palindrome
Digit Frequency
2 1
3 1
7 1
8 1
9 2
```

3. **Defined as a function F as Fn = Fn-1 + Fn-2. Write a Python program which accepts a value for N (where N >0) as input and pass this value to the function. Display suitable error message if the condition for input value is not followed.**

Source Code:

```
# Function for nth Fibonacci number
def Fibonacci(n):
if n == 1:
return 0
elif n == 1 or n == 2:
return 1
else:
return Fibonacci(n-1) + Fibonacci(n-2)
count = 1
N = int(input("Enter a value of N : "))
if N<=0:
print("Invalid Input: Enter a value of N (>0)")
else:
print("Fibonacci sequence : ")
while count <= N:
print(Fibonacci(count),end=' ')
nexterm = t1 + t2
# update values
t1 = t2
t2 = nexterm
count += 1
```

Output:

```
Enter a value of N : 10
Fibonacci sequence :
0 1 1 2 3 5 8 13 21 34
```

**4. Develop a python program to convert binary to decimal, octal to hexadecimal using functions.**

Source code for binary to decimal: :

```
def bintodecima(b_num):
value = 0
for i in range(len(b_num)):
digit = b_num.pop()
if digit == '1':
value = value + pow(2, i)
return value
b_num = list(input("Input a binary number: "))
value = bintodecima(b_num)
print("The decimal value of the number is", value)
```

Output:

```
Input a binary number: 100
The decimal value of the number is 4
```

Source code for octal to hexadecimal:

```
# Octal to Hexadecimal using List and while Loop
print("Enter the Octal Number: ")
octnum = int(input())
chk = 0
i = 0
decnum = 0
while octnum!=0:
rem = octnum%10
if rem>7:
chk = 1
break
decnum = decnum + (rem * (8 ** i))
i = i+1
octnum = int(octnum/10)
if chk == 0:
i = 0
hexdecnum = []
while decnum != 0:
rem = decnum % 16
if rem < 10:
rem = rem + 48
else:
rem = rem + 55
rem = chr(rem)
hexdecnum.insert(i, rem)
i = i + 1
decnum = int(decnum / 16)
print("\nEquivalent Hexadecimal Value is: ")
i = i - 1
while i >= 0:
print(end=hexdecnum[i])
i = i - 1
print()
else:
print("\nInvalid Input!")
```

Output :

```
Enter the Octal Number:
7302
Equivalent Hexadecimal Value is:
EC2
```

**5. Write a Python program that accepts a sentence and find the number of words, digits, uppercase letters and lowercase letters.**

Source Code:

```
sentence = input("Enter a sentence: ")
(words, digits, upper, lower) = (0, 0, 0, 0)
l_w = sentence.split()
words = len(l_w)
for ch in sentence:
if ch.isdigit():
digits = digits + 1
elif ch.isupper():
upper = upper + 1
elif ch.islower():
lower = lower + 1
print ("No of Words: ", words)
print ("No of Digits: ", digits)
print ("No of Uppercase letters: ", upper)
print ("No of Lowercase letters: ", lower)
```

Output :

```
Enter a sentence: I am Palguni GT and My usn is 12345_MCE
No of Words: 9
No of Digits: 5
No of Uppercase letters: 8
No of Lowercase letters: 17
```

**6. Write a Python program to find the string similarity between two given strings**

```
Sample Output:
Original string:
Python Exercises
Python Exercises
Similarity between two said strings:
1.0
Sample Output:
Original string:
Python Exercises
Python Exercise
Similarity between two said strings:
0.967741935483871
```

Source Code:

Output:

**7. Write a python program to implement insertion sort and merge sort using lists**

Source Code:

Output:

**8. Write a program to convert roman numbers in to integer values using dictionaries.**

Source Code:

Output:

**9. Write a function called isphonenumber () to recognize a pattern 415-555-4242 without using regular expression and also write the code to recognize the same pattern using regular expression. **

Source Code:

Output:

**10. Develop a python program that could search the text in a file for phone numbers (+919900889977) and email addresses (sample@gmail.com)**

Source Code:

Output:

**11. Write a python program to accept a file name from the user and perform the following operations : 1. Display the first N line of the file and 2.Find the frequency of occurrence of the word accepted from the user in the file**

Source Code:

Output:

**12.Write a python program to create a ZIP file of a particular folder which contains several files inside it.**

Source Code:

Output:

**13.By using the concept of inheritance write a python program to find the area of triangle, circle and rectangle.**

Source Code:

Output:

**14.Write a python program by creating a class called Employee to store the details of Name, Employee_ID, Department and Salary, and implement a method to update salary of employees belonging to a given department.**

Source Code:

Output:

**15. Write a python program to find the whether the given input is palindrome or not (for both string and integer) using the concept of polymorphism and inheritance.**

Source Code:

Output:

**16. Write a python program to download the all XKCD comics**

Source Code:

Output:

**17. Demonstrate python program to read the data from the spreadsheet and write the data in to the spreadsheet**

Source Code:

Output:

**18. Write a python program to combine select pages from many PDFs**

Source Code:

Output:

**19. Write a python program to fetch current weather data from the JSON file**

Source Code:

Output:

**Part B (Practical Based Learning ):**

A problem statement for each batch is to be generated in consultation with the co-examiner and student should develop an algorithm, program and execute the program for the given problem with appropriate outputs.