0% found this document useful (0 votes)
4 views5 pages

Mod2 QB

The document outlines a series of programming questions for a B.Tech course on Python, covering various topics such as encryption, file operations, functions, and data structures. Each question includes specific tasks, such as writing programs, explaining concepts, and providing examples. The questions are categorized into modules and submodules, with varying levels of difficulty and marks assigned.

Uploaded by

av.krishna.10a
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Mod2 QB

The document outlines a series of programming questions for a B.Tech course on Python, covering various topics such as encryption, file operations, functions, and data structures. Each question includes specific tasks, such as writing programs, explaining concepts, and providing examples. The questions are categorized into modules and submodules, with varying levels of difficulty and marks assigned.

Uploaded by

av.krishna.10a
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Vimal Jyothi Engineering College

(Autonomous)
DEPARTMENT OF
VIth Semester - [Link]
Course : CST362 - PROGRAMMING IN PYTHON

QNo QUESTION CO MARK


Module 2
Submodule 1

1. a) Define the concept of Caesar cipher and write the programs for encryption and

decryption with distance +3 for the lowercase alphabet. (8 Marks)


CO3 (14.00)
b) Write a Python program to convert a decimal number to its binary equivalent.

(6 Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Others ) (Prev Year KTU (May 2024) )
Topic 1

2. a) Write a Python program to remove the nth index character from a non-empty string. (7

Marks) CO3 (14.00)


b) Explain about data encryption in detail. (7 Marks)
( Problem ) ( Applying(P) ) ( Hard ) (Ref : Unknown ) ( )

3. a) Write a Python program to convert a decimal number to its binary equivalent. (7

Marks)
CO3 (14.00)
b) Write a Python program to get a string and change all occurrences of its first character

to ‘$’ except the first character itself. (7 Marks)


( Problem ) ( Applying(P) ) ( Hard ) (Ref : Unknown ) ( )

4. a) Assume that the variable data refers to the string "Python rules!". Use a string method

to perform the following tasks: (7 Marks)

1. Obtain a list of the words in the string.


2. Convert the string to uppercase.
3. Locate the position of the string "rules".
4. Replace the exclamation point with a question mark.

b) Write a Python program to check the validity of a password given by the user. The CO3 (14.00)

password should satisfy the following criteria: (7 Marks)

1. Contains at least one letter between a and z.


2. Contains at least one number between 0 and 9.
3. Contains at least one letter between A and Z.
4. Contains at least one special character from $, #, @.
5. Minimum length of password: 6.

( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )


5. Explain how the [Link]() method works in Python and provide an example of its usage. CO3 (3.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

6. Explain why strings are considered immutable data structure in programming? CO3 (3.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

1 of 5
7. Write the output of following Python code: S = “Computer”.

1. print(S[::2])
CO3 (3.00)
2. print(S[::-1])
3. print(S[:])

( Theory ) ( Applying(P) ) ( Easy ) (Ref : Unknown ) ( )


Submodule 2
Topic 1

8. a) Explain about basic file operations in Python. Write a Python program that generates

random numbers between 1 and 500 and store them in a text file. (7 Marks)
CO3 (14.00)
b) Write a Python program to count the lines, word, and characters within a text file. (7

Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

9. a) Write a Python program to read a text file and store the count of occurrences of each

character in a dictionary. (7 Marks)


CO3 (14.00)
b) Write a Python program that inputs a text file. The program should print the unique

words in the file in alphabetical order. (7 Marks)


( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

10. a) Write a Python code segment that opens a file for input and prints the number of four-
letter words in the file. (7 Marks)

b) Assume that there is a text file named “[Link]”. Write a Python program to find CO3 (14.00)
the median of the list of numbers in the file without using the standard function for

median. (7 Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

11. How do the read() and readline() methods in Python differ when reading from a file?
CO3 (3.00)
Explain with examples.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

12. Write a Python program that reads the content of a file, reverses it, and then prints the
CO3 (3.00)
reversed content.
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

13. Write Python code to perform the following tasks:

1. Writes the text” PROGRAMMING IN PYTHON” to a file with name [Link]. CO3 (3.00)
2. Then reads the text again and prints it to the screen.

( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )


Submodule 3
Topic 1

14. a) Explain how to pass default arguments to a function in Python. Write a function that

accepts a name and age, with a default age of 30. (7 Marks)


CO3 (14.00)
b) What is a function in Python, and how is it defined and called? Give an example. (7

Marks)
( Theory ) ( Applying(P) ) ( Easy ) (Ref : Unknown ) ( )

2 of 5
15. a) Explain how you can return multiple values from a Python function. Give an example

that returns the sum and product of two numbers. (7 Marks)


CO3 (14.00)
b) Explain the concept of scope and lifetime of variables in Python programming

language, with a suitable example. (7 Marks)


( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

16. a) Create a function min_max() that takes n numbers as a list argument and returns the
smallest and largest number. (7 Marks)
CO3 (14.00)
b) Using a function, write a Python program to check if a given string is a palindrome. (7
Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

17. What is mapping in Python, and how does the map() function work? Provide an
CO3 (3.00)
example.
( Theory ) ( Understanding(U) ) ( Easy ) (Ref : Unknown ) ( )

18. What are the key steps involved in problem-solving using top-down design? CO3 (3.00)
( Theory ) ( Remembering(R) ) ( Easy ) (Ref : Unknown ) ( )

19. What are the advantages of using functions in programming? CO3 (3.00)
( Theory ) ( Understanding(U) ) ( Easy ) (Ref : Unknown ) ( )
Submodule 4
Topic 1

20. Define higher order functions used for mapping, filtering and reducing with example. CO3 (3.00)
( Problem ) ( Remembering(R) ) ( Medium ) (Ref : Others ) (Prev Year QP KTU(May 2024) )

21. a) What is infinite recursion in Python, and how can you trace a recursive function to
identify it? (7 Marks) CO3 (14.00)
b) Write a recursive Python function to generate Fibonacci numbers. (7 Marks)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

22. a) What is a higher-order function in Python? Explain with an example using the reduce()
function. (7 Marks)
b) Write a recursive Python function to calculate the sum of digits of a given number. (7 CO3 (14.00)

Marks)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

23. a) Use higher order Python function filter to extract a list of positive numbers from a
given list of [Link] lambda to create the auxiliary function. (7 Marks) CO3 (14.00)
b) Write a recursive function in Python to find the sum of two numbers. (7 Marks)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

24. Explain lambda function with an example. CO3 (3.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

25. Write a recursive function in Python to find the factorial of a number. CO3 (3.00)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

26. Write a recursive function in Python to find the product of two numbers. CO3 (3.00)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )
Submodule 5
Topic 1

3 of 5
27. a) Write a Python program to get a list of colours and display the first and last colour from
the list. (7 Marks)
CO3 (14.00)
b) Write a Python program to read n integers into a list and separate the positive and
negative numbers into two different lists. (7 Marks)
( Problem ) ( Applying(P) ) ( Hard ) (Ref : Unknown ) ( )

28. a) Write a Python program to find the largest number in a list without using built-in

functions. (7 Marks) CO3 (14.00)


b) Write a Python program to insert a number to any position in the list. (7 Marks)
( Problem ) ( Applying(P) ) ( Hard ) (Ref : Unknown ) ( )

29. a) Write a Python program to read a list of numbers and sort the list in a non-decreasing
order without using any built-in functions. Separate function should be written to sort the
list wherein the name of the list is passed as the parameter. (7 Marks) CO3 (14.00)
b) Write a Python program to read n integers into a list and separate the positive and
negative numbers into two different lists. (7 Marks)
( Problem ) ( Applying(P) ) ( Hard ) (Ref : Unknown ) ( )

30. Write a Python program to search a given element in a list. CO3 (3.00)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

31. Write a Python program to create a list of squares for the numbers from 0 to 9 using list
CO3 (3.00)
comprehension.
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

32. Illustrate the use of negative indexing of lists with examples. CO3 (3.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )
Submodule 6
Topic 1

33. a) Write a Python program to find maximum, minimum and sum of n numbers in a tuple.
(7 Marks)
b) Write a Python script to print a dictionary where the keys are the numbers between 10 CO3 (14.00)

and 15 (both included) and the values are the square of the keys. (7 Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

34. a) Illustrate the following set methods with an example. (7 Marks)

1. intersection( )
2. union( )
3. issubset( )
4. difference()
5. update() CO3 (14.00)
6. discard()

b) Write a Python script to print a dictionary where the keys are the numbers between m
and n and the values are the square of the keys. (7 Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

4 of 5
35. a) Write a Python program to find the frequency of each character in a given string and
store the count in a dictionary with key as the character. (7 Marks)
CO3 (14.00)
b) Create a dictionary of names and birthdays. Write a Python program that asks the
user enters a name, and the program displays the birthday of that person. (7 Marks)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

36. Write a Python script to merge two Python dictionaries. CO3 (3.00)
( Problem ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

37. What is a dictionary? Explain the methods available in the dictionary. CO3 (3.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

38. Differentiate between the tuple and sets in Python. CO3 (3.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

5 of 5

You might also like