0% found this document useful (0 votes)
4 views

Python QB ans

The document outlines key features and applications of Python, highlighting its ease of use, interpreted nature, and extensive libraries. It also discusses important concepts such as variables, dictionaries, and built-in functions, along with their usage in programming. Additionally, it provides examples of Python's application in web development, data science, machine learning, and automation.

Uploaded by

Ronit Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Python QB ans

The document outlines key features and applications of Python, highlighting its ease of use, interpreted nature, and extensive libraries. It also discusses important concepts such as variables, dictionaries, and built-in functions, along with their usage in programming. Additionally, it provides examples of Python's application in web development, data science, machine learning, and automation.

Uploaded by

Ronit Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1

Q2
ANS:
key features of Python:
1. Easy to Learn & Use – Python has a simple syntax similar to English, making it beginner-friendly.
2. Interpreted Language – Python executes code line by line, making debugging easier.
3. Object-Oriented & Procedural – Supports both programming paradigms for flexibility.
4. Extensive Libraries – Provides built-in modules for tasks like data handling, web development, and AI.
5. Platform-Independent – Runs on multiple operating systems like Windows, Mac, and Linux without modification.

For a 2-mark answer, you can write:


"Python is an easy-to-learn, interpreted, and platform-independent language. It supports both object-oriented and
procedural programming and has extensive libraries for various applications."

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.

Operators Used in Python:


1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Assignment Operators
5. Bitwise Operators

Q7
ANS:
-A dictionary in Python is a built-in data structure that stores data as key-value pairs.
-Each item in a dictionary consists of a key and a corresponding value.
-The key acts as an identifier for the value, and you can use it to access the value efficiently.
-Dictionaries in Python are mutable, meaning that you can modify them by adding, updating, or removing key-value pairs.
-To create a dictionary, you use curly braces {} with key-value pairs separated by colons :.
-For example, {'name': 'Alice', 'age': 30} is a dictionary with two key-value pairs.
-Keys must be unique within a dictionary, and they are typically strings, numbers, or tuples.
-Values, on the other hand, can be of any data type.

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.
-In Python, variables do not require explicit type declarations, as Python automatically determines the type of a variable
based on the assigned value.
-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 characteres are used execpt underscore(_) in variable declarartion.
6.Variable can be of unlimited length
-Eg.,
>>> 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.

Categories of Built-in Functions :


1. Basic Input/Output Functions
- print() – Displays output.
- input() – Takes user input.

2. Type Checking & Conversion Functions


- type(x) – Returns the type of x.
- str(x) – Converts x to a string.
- int(x) – Converts x to an integer.
- float(x) – Converts x to a floating-point number.
3. String Functions
- len(s) – Returns the length of a string.
- lower() – Converts a string to lowercase.
- upper() – Converts a string to uppercase.
- replace(a, b) – Replaces a with b in a string.
4. Mathematical Functions
- abs(x) – Returns the absolute value of x.
- max() – Returns the largest value.
- min() – Returns the smallest value.
- sum(iterable) – Returns the sum of numbers.
5. List & Tuple Functions
- list(iterable) – Converts an iterable to a list.
- tuple(iterable) – Converts an iterable to a tuple.
- sorted(iterable) – Returns a sorted list.
- len(iterable) – Returns the number of elements in a list or tuple.

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.

You might also like