Python Model Question solution

5th semester New Syllabus

Group A

Python SAQ_watermark_page-0001

Python SAQ_watermark_page-0002

Group B

11.

Membership operators in Python are used to test whether a value or variable exists in a sequence (such as a string, list, tuple, set, or dictionary). There are two membership operators: in and not in.

  • in Operator: This operator checks if a specified value is present in a sequence. If the value is found, it returns True; otherwise, it returns False.
  • not in Operator: This operator checks if a specified value is not present in a sequence. If the value is not found, it returns True; otherwise, it returns False.

 

 

12. Write a program to count the number of vowels in a string.

15.Write a program using a function to find the sum of any numbers passed to the function.

16 . How do you draw multiple plots in a single figure using Matplotlib?

 

Group C: Long Answer Questions

17. Write a program to check if a number entered is prime or not.

18.Explain match-case statement with a suitable example.

The match-case statement, introduced in Python 3.10, is similar to a switch-case statement found in other languages. It allows you to match patterns in a value or object and execute code blocks based on those patterns

19.

List comprehension is a concise way to create lists in Python. It allows for the generation of lists based on existing lists, and it can include a conditional statement for filtering.

 

20.

Method overriding occurs when a subclass provides a specific implementation for a method that is already defined in its superclass. The overridden method in the subclass has the same name, parameters, and return type as the method in the superclass.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *