https://machinelearningmastery.com/wp-content/uploads/2022/04/cheatsheet.png
iris = 'http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
may-29-2024 python test - https://docs.google.com/document/d/1BteXGqjfn60F3loMl1953UCDn9GGXZ8z/edit?usp=sharing&ouid=114028356553080472739&rtpof=true&sd=true
PYTHON TEST MAY 2023
PART - 1
- Explain your understanding about OOPS?
- Pros and cons in OOPS?
- What is a class in Python? Explain with an example.
- How do you access class members?
- What is an object in Python? Explain with an example.
- What is inheritance in Python? Explain with an example.
- Draw the types of inheritance?
- How do you create a subclass in Python?
- What is polymorphism in Python? Explain with an example.
- How do you implement polymorphism in Python?
- What is encapsulation in Python? How do you implement it?
- How do you define an abstract class in Python?
- How will you create constructor in Python?
- Write a program using class to store name and marks of students in list and print total marks.
- Find the error in the following program to get the given output? class Fruits: def init(self, f1, f2): self.f1=f1 self.f2=f2 def display(self): print("Fruit 1 = %s, Fruit 2 = %s" %(self.f1, self.f2)) F = Fruits ('Apple', 'Mango') del F.display F.display()
Output: Fruit 1 = Apple, Fruit 2 = Mango
PART-2
String Manipulation
- Write a python program to find the length of a string. Without using len() function.
- What is string slicing explain with examples.
- Write a Python code snippet to check if a given substring is present in a given string. Input: ‘abcd’ Output: a,ab,abc,abcd b,bc,bcd c,cd d
- Built-in String functions. Explain any 5 with examples.
- Explain the code with output. What will be your output if you try these slicing operations. a. (str1[10:16]) b. (str1[10:16:4]) c. (str1[10:16:2]) d. (str1[::3]) Input: str1="Welcome to learn Python"
- Program that accept a string from the user and display the same after removing vowels from it?
- What will be the output of the given python program? str1 = "welcome" str2 = "to school" str3=str1[:2]+str2[len(str2)-2:] print(str3)
- Write a Python program to display the given pattern C O M P U T E R C O M P U T E C O M P U T C O M P U C O M P C O M C O C
List Manipulations
- What is a list in Python? Explain its purpose and how it differs from other data types.
- How do you create an empty list in Python? Provide an example.
- What is the difference between append() and extend() methods in Python lists? Explain with an example.
- Explain the concept of list comprehension in Python. Provide an example of list comprehension to filter even numbers from a given list.
- What are the built-in functions for manipulating lists in Python? Provide examples for at least three different built-in functions.