Python QB
Python QB
Q3
ANS:
Applications of Python:
1. Web Development: Django, Flask, FastAPI
2. Data Science & Analytics: Pandas, NumPy, Matplotlib
3. Machine Learning & AI: TensorFlow, Scikit-learn, PyTorch
4. Automation & Scripting: Selenium, PyAutoGUI
5. Game Development: Pygame, Panda3D
Q4
ANS:
-indentation is crucial as it defines the structure of the code and determines how statements are grouped.
-Unlike other languages that use braces {}, Python relies on indentation to indicate blocks of code.
Q5
ANS:
-An operator in Python is a symbol that performs an operation on values or variables.
-Operators are used in mathematical calculations, comparisons, and logical expressions.
Q7
ANS:
-A dictionary in Python stores data as key-value pairs using {}.
-Keys must be unique and are usually strings, numbers, or tuples, while values can be any data type.
-Dictionaries are mutable, allowing adding, updating, and removing items.
-Example: {'name': 'Alice', 'age': 30}.
4 Marks
Q2
ANS:
key features of Python:
1.Easy to Learn and Use - Python has a simple and readable syntax, making it beginner-friendly.
2.Interpreted Language - Python executes code line by line (no need for compilation), making debugging easier.
3.Dynamically Typed - No need to declare variable types; Python automatically determines the data type.
4.Object-Oriented and Procedural - Supports both object-oriented and procedural programming paradigms.
5.Platform Independent -Python code can run on different operating systems without modification.
6.Large Standard Library - Comes with built-in modules for handling tasks like file handling, networking, and
data processing.
7.Extensible and Embeddable - Can integrate with other languages like C, C++, and Java for enhanced
functionality.
8.High-Level Language - Python manages memory allocation and garbage collection automatically.
9.Supports GUI and Web Development - Libraries like Tkinter, Django, and Flask allow building graphical
applications and web applications.
Q1
ANS:
Q8
ANS:
-A variable in programming is a name that refers to a memory location where data can be stored.
-It acts as a container for holding values or data types (such as integers, strings, floats, etc.) that can be used and
manipulated throughout a program.
-Rules for Declaring Variables in Python:
1.Variables in python can be created from alphanumeric character and underscore (_) character.
2.A variable cannot begin with a number.
3.The variable are case sensative.
4.Variable name should not be reserved word or keyword.
5.No special characters are used except underscore (_) in variable declaration.
6.Variable can be of unlimited length
-E.g.,
>>> a = 10
>>> print(a)
10
Q9
ANS:
r = float(input("Enter radius: "))
h = float(input("Enter height: "))
pi = 3.1416 # Approximate value of π
volume = pi * r * r * h
surface_area = 2 * pi * r * (r + h)
print("Volume:", volume)
print("Surface Area:", surface_area)
Q10
ANS:
Built-in Functions in Python:
-Python provides built-in functions that are readily available for use without needing to import any modules.
-These functions help perform common tasks like mathematical operations, input/output handling, type conversions, and
more.
6. Utility Functions
- id(x) – Returns the memory address of x.
- help(x) – Displays help information about x.
- range(start, stop, step) – Generates a sequence of numbers.