0% found this document useful (0 votes)
37 views4 pages

Python 1

I
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
37 views4 pages

Python 1

I
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

1.

Write a python program to read the weight of an object in grams and display its weight in kilograms
and grams, respectively.

2.Write a python program to read number of rows from the users and print pattern as follows.

Sample input:

Number of Row: 4

Sample Output:

2*2

3*3*3

4*4*4*4

127

3. Write a program with a function to check whether the last digit of a number (entered by user) is
divisible by 3 or not.

4. Write a program to take a string as input and return the characters of the string whose ASCII value
is even.

Sample Input: Operator

Sample Output:

p 112

r 114

t 116

r 114

5.Given a list of integers with duplicate elements in it. The task is to generate another list, which
contains only the duplicate elements. Write a python program for the same

Input: list = [10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]

Output: output_list = [20, 30, -20, 60]

6.Create a tuple of names and find the number of occurrences of each name in the tuple using a
python program.

7. Anita has to display encoded message where she has to capitalize first letter of each word and
display output. Write a Python program for the same. Example: Input: “Treasure is in the cabinet”
Output: Treasure Is In The Cabinet
8. Write a python program to read the marks of 'n' students in a course as a tuple and find the sum,
average, highest and lowest marks.

9. Consider a dictionary, write a python program to create a dictionary with the key as the
first character and value as words starting with that character.
Sample Input and Output:
Input: Hello World
Output: {'H': ['Hello'],
'W': ['World']}
10. In a pizza outlet, there are 2 service counters. Tokens are issued to the customers from 51 to 75.
Counter 1 serves the customers whose token numbers are multiples of 5 only and counter 2 serves
the rest of them. Write a program to create a list of token numbers to be served by counter 1 and
counter 2

11. Given a list of employee names, write a program to create a dictionary in which the key is the
number of characters in the name and values is all the names of that length.
Example: Input: [‘Manav’, ‘Surabhi’, ‘Aditi’] Output: {5:[‘Manav’,’Aditi’], 7:[‘Surabhi’]}

12. Given a list of 5 strings, write a python program to count the number of palindrome strings in it.

13. The college decides to give scholarship to students scoring a CGPA of more than 9.0. Given a
dictionary containing USN: CGPA as key value pairs, write a python program to create a new
dictionary containing the details of students eligible for scholarship.

14. Write a python program to find and print the prime numbers from the input list defined by the
user.
15. Given a line of text that contains the email ID of user, write a python program to identify the
domain name of the user.
Example, input line: “ Sunday, June 2023, admin@bmsce.ac.in ” Output: bmsce
16. It is December. Time for Salary Hike! A small firm has 5 employees working for it. The
management has decided to provide hike to them, based on the following conditions. If the salary is
below10000, 7% hike is given.
If the salary is between 10000 to 20000, 10% hike is given.
If the salary is between 20000 to 25000, 12% hike is given.
If the salary is 25000 and above, 15% hike is given.
Write a python program to take appropriate input and compute the updated salary for all
employees.
17. i. Define a tuple. Write a python program to search an element in a tuple consisting of ‘n’
numbers.
ii. Demonstrate the difference between the write and append mode in files with a suitable program
as an example.

UNIT - III

1.Explain the inheritance and its types feature of object-oriented programming in Python with an
example.
2.Write a Python program that prompts the user to input an integer and raises a Value Error
exception if the input is not a valid integer.

3.With an example, illustrate Exception handling. List and discuss any 5 pre-defined exceptions in
Python.

4. Explain the encapsulation feature of object-oriented programming in Python with an example


program.

5. Analyze the given python code and write the output. Identify the errors in the given python code,
correct the code and write expected output for corrected code.

6. Analyze the given python code and write the output. Identify the errors in the given python code,
correct the code and write expected output for corrected code.
Develop a Python program to create a class Bank account with attributes account_num, balance,
account type, and customer_name. i. The program should include methods: deposit, withdraw, and
check_balance.
ii. Create 3 objects and demonstrate method calling.
Develop a python program to create a class Transaction with members trans_id, and amount.
i. Create a class business_transaction that inherits from Transaction and has business_id as
a member.
ii. ii. Define a method to display the business details. iii. Create relevant objects and
demonstrate method calling.

UNIT - IV

1.Write a Python program to match a string that contains only upper and lowercase letters, numbers,
and underscores.

2.Write a program to compute the number of character words and lines in a file

3.Write a program that writes numbers from 1 to 20 to the output file “WriteNumbers.txt”

Define Regular expression with an example. Write a program for implementing Regular Expression
Matching.

Write a program to demonstrate Readline().

UNIT - V

1 What is Database connectivity. Explain Database connectivity with python with example.

2. Define mail data. Explain visualizing mail data with example.

Explain the process of Visualizing networks and interconnections.


Illustrate Data Manipulation Language in SQL with an example.

You might also like