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

All Python Answers Exam Style

The document provides an introduction to Python, covering its features, string manipulation, lists, tuples, dictionaries, and functions. It also discusses modules, packages, object-oriented programming concepts, exception handling, GUI programming with Tkinter, and basics of data science including NumPy, Pandas, and machine learning. Each section includes explanations and examples to illustrate the concepts.

Uploaded by

kdkunaldalvi5381
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 views7 pages

All Python Answers Exam Style

The document provides an introduction to Python, covering its features, string manipulation, lists, tuples, dictionaries, and functions. It also discusses modules, packages, object-oriented programming concepts, exception handling, GUI programming with Tkinter, and basics of data science including NumPy, Pandas, and machine learning. Each section includes explanations and examples to illustrate the concepts.

Uploaded by

kdkunaldalvi5381
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

LESSON – 1 : INTRODUCTION TO PYTHON

This lesson deals with features of Python, string manipulation, lists,


tuples, dictionary, and functions.

Q1. Explain features of Python.

Python is a simple, powerful and widely used programming language. 1.


Simple & Readable: The syntax is very clean. 2. Interpreted: Executes
line-by-line. 3. Object-Oriented: Supports classes and objects. 4.
Dynamically Typed: No need to declare variable types. 5.
Cross-platform: Works on Windows, Linux, macOS. 6. Large Library
Support: Math, OS, Random, Tkinter etc. 7. Free & Open Source:
Community-driven. 8. Extensible: Integrates with C/C++ easily.

Q2. Explain string manipulation.

String manipulation means performing actions like slicing, indexing,


replacing, searching etc. Examples: • [Link](), [Link]() •
[Link]('a','b') • [Link](), ' '.join(list) • s[0:4] for slicing Strings are
immutable so operations return new strings.

Q3. Explain list in detail.

List is an ordered, mutable collection. Example: L = [10,20,'apple']


Operations: append(), extend(), pop(), remove(), insert(), sort(),
reverse() Lists support slicing, indexing, and allow duplicates.

Q4. Explain tuple in detail.

Tuple is ordered but immutable. Example: t = (1,2,3) Faster than list and
used for fixed data. Supports count() and index() methods.

Q5. Explain dictionary manipulation.

Dictionary stores data in key-value pairs. Example: d =


{'name':'Kunal','age':20} Operations: • d['city']='Pune' (add) •
[Link]({'age':21}) • del d['age'] • [Link](), [Link]() Dictionary is
fast due to hashing.

Q6. Define function and types of functions.

Function is a reusable block of code. Types: • Built-in functions •


User-defined functions • Lambda functions • Recursive functions
Q7. Explain local & global variables.

Local variable exists inside function. Global variable exists outside


function. Example: x = 10 def fun(): y = 20 print(x,y)
LESSON – 2 : MODULES AND PACKAGES

This lesson covers modules, packages and importing.

Q1. What is module and how to create it?

A module is a Python file containing code, functions or classes. Creating


module: [Link] def add(a,b): return a+b Import: import mymod

Q2. Explain built-in modules.

Python provides ready modules like: • math – mathematical functions •


random – random numbers • datetime – date and time • os – operating
system functions • sys – system methods

Q3. What is package & how to create?

Package = folder containing modules + __init__.py Example: mypack/


__init__.py [Link] Import: from mypack import mod1

Q4. Explain predefined packages with example.

Examples: • NumPy – arrays • Pandas – DataFrame • Matplotlib – graphs


Example: import numpy as np a = [Link]([1,2,3])
LESSON – 3 : OBJECT ORIENTED PROGRAMMING

This lesson covers class, object, inheritance etc.

Q1. What is class & object?

Class is a blueprint. Example: class Student: pass Object: s = Student()

Q2. Class methods.

Types: • Instance method – uses self • Class method – uses


@classmethod • Static method – uses @staticmethod

Q3. Inheritance & types.

Inheritance allows new class to use old class features. Types: • Single •
Multiple • Multilevel • Hierarchical • Hybrid

Q4. Explain IS-A & HAS-A.

IS-A → Inheritance Dog IS-A Animal HAS-A → Composition Car HAS-A


Engine

Q5. Program: Rectangle area & volume.

class Rectangle: def __init__(self,l,b,h): self.l=l; self.b=b; self.h=h def


area(self): return self.l*self.b def volume(self): return self.l*self.b*self.h
LESSON – 4 : EXCEPTION HANDLING

This lesson explains try-except, finally, assert etc.

Q1. Common exceptions.

ZeroDivisionError, ValueError, TypeError, IndexError, KeyError,


FileNotFoundError.

Q2. Explain try-except-else.

try: code except: handle error else: executes only if no error

Q3. Explain try-finally.

finally always runs. Used to close files/resources.

Q4. Explain assert statement.

assert is used for debugging. Example: assert x > 0


LESSON – 5 : GUI PROGRAMMING (Tkinter)

This lesson explains GUI components.

Q1. Explain GUI methods.

Tk(), mainloop(), geometry(), title(), widgets etc.

Q2. Tkinter example.

from tkinter import * root = Tk() [Link]('200x200')


[Link]()

Q3. Explain widgets.

Label, Button, Entry, Frame, RadioButton, CheckButton, Text

Q4. Geometry management.

pack(), grid(), place()

Q5–Q8. Frame, Button, Label, Entry.

Frame groups widgets. Button executes command. Label displays text.


Entry accepts user input.
LESSON – 6 : DATA SCIENCE BASICS

This lesson covers NumPy, Pandas, ML, NLP.

Q1. NumPy, SciPy, Pandas.

NumPy – numerical computing SciPy – scientific computing Pandas –


data analysis

Q2. Data visualization.

Data is represented using graphs like bar, line, histogram using


Matplotlib.

Q3. Deep learning.

Deep learning uses neural networks (ANN, CNN, RNN) for images,
speech, NLP.

Q4. Data modeling & ML.

Data modeling structures data. Machine learning learns patterns from


data for prediction.

Q5. NLP.

Natural Language Processing enables computers to understand human


language.

You might also like