0% found this document useful (0 votes)
6 views3 pages

Important Python Questions Unit1

Uploaded by

rathibhumi636
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Important Python Questions Unit1

Uploaded by

rathibhumi636
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Important Questions & Answers – Python Programming (Unit I)

What is Python? Who developed it?


Definition: Python is a high-level, interpreted programming language known for its simple
syntax and readability.
Developer: Python was created by Guido van Rossum and released in 1991.
Key Features:
1. Supports multiple programming paradigms (object-oriented, procedural, functional).
2. Cross-platform compatibility.
3. Extensive standard libraries.
4. Easy integration with other languages like C, C++, and Java.
Example Code:
```python
print("Hello, World!")
```

Why is Python popular among beginners?


Reasons:
1. Simple Syntax: Close to English, making it easy to learn.
2. Extensive Libraries: Prebuilt modules for data science, AI, web development, etc.
3. Versatile Applications: From web development to AI and automation.
4. Large Community Support: Huge online resources and forums.

Explain variables in Python and how they are declared.


Definition: Variables are containers for storing data values.
Declaration: In Python, a variable is created when you assign a value to it (no explicit
declaration needed).
Example:
```python
x=5 # integer
name = "Raj" # string
```
Rules for Naming Variables:
1. Must start with a letter or underscore `_`.
2. Cannot start with a digit.
3. Only alphanumeric characters and underscores are allowed.
4. Case-sensitive.
5. Cannot be a Python keyword.

Explain f-strings in Python with an example.


Definition: f-strings (formatted string literals) allow embedding expressions inside string
literals using {}.
Advantages:
1. Concise and readable.
2. Faster than format() and % formatting.
Example:
```python
name = "Sonal"
age = 25
print(f"My name is {name} and I am {age} years old.")
```
Output:
My name is Sonal and I am 25 years old.

List different types of operators in Python with examples.


1. Arithmetic Operators: +, -, *, /, %, **, //
Example: 5 + 3 → 8
2. Assignment Operators: =, +=, -=, *=, /=, //=, **=, %=
3. Comparison Operators: ==, !=, >, <, >=, <=
4. Logical Operators: and, or, not
5. Identity Operators: is, is not
6. Membership Operators: in, not in
7. Bitwise Operators: &, |, ^, ~, <<, >>

What is programming and why is it necessary?


Programming is the process of writing instructions for a computer to perform tasks.
It is necessary because:
1. Automates repetitive tasks.
2. Helps in data processing and analysis.
3. Enables software and application development.
4. Used in AI, IoT, robotics, and more.

Explain the rules for naming variables in Python.


Rules:
1. Must start with a letter or underscore.
2. Cannot start with a number.
3. Only letters, digits, and underscores allowed.
4. Case-sensitive.
5. Cannot use Python keywords.

Mention any four applications of Python.


1. Web Development (Django, Flask)
2. Data Science & Machine Learning
3. Automation & Scripting
4. Game Development (Pygame)
Why is Python known as an interpreted language?
Python executes code line-by-line at runtime without prior compilation.
The Python interpreter reads each line, interprets it, and executes it immediately.

Write a Python expression to calculate the area of a circle.


Example:
```python
radius = 5
area = 3.14159 * radius ** 2
print("Area of circle:", area)
```

You might also like