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

Untitled Document

Uploaded by

mpjain281120
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)
5 views3 pages

Untitled Document

Uploaded by

mpjain281120
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
You are on page 1/ 3

**1.

Python Programming and its Importance**

Python is a high-level, general-purpose programming language known for its readability,


simplicity, and versatility. It is widely used for web development, data science, machine
learning, automation, and more. Learning Python is crucial in the 21st century due to its
applicability across many fields and the rising demand for programming skills in the job
market.

**Benefits of Python:**
1. Easy to read and w
2. Extensive libraries and frameworks.
3. High compatibility with other languages.
4. Robust community support.
5. Ideal for beginners and experts alike.
6. Supports multiple paradigms (e.g., OOP, functional).
7. Great for web and app development.
8. Essential in data science and AI.
9. Platform-independent.
10. Effective for rapid prototyping.

**ii. Program for Different Number Data Types in Python**


```python
# Different number data types in Python
a = 10 # Integer
b = 15.5 # Float
c = 2 + 3j # Complex

print("Integer:", a)
print("Float:", b)
print("Complex:", c)
```

---

**2. i. Output of `print(0.1 + 0.2 == 0.3)`**

Answer: **False**

**Justification**: Due to floating-point precision errors, `0.1 + 0.2` does not exactly equal
`0.3` in binary representation.

**ii. Incorrect Declaration**

Answer: **d) None of these**

**Justification**: All given options (_x, __x, __xyz__) are valid in Python.

**iii. Program for Arithmetic Operations**


```python
# Arithmetic operations
a = 10
b=3

print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Modulus:", a % b)
print("Exponent:", a ** b)
print("Floor Division:", a // b)
```

---

**3. i. Convert String to Object in Python**

You can convert a string representing Python code into an object using `eval()` (use with
caution for safety):
```python
obj = eval("42")
print(obj)
```

**ii. Get a Random Number and List Manipulation Program**


```python
import random

# Generate random number


print("Random number:", random.randint(1, 100))

# List operations
my_list = [1, 2, 3]
my_list.append(4)
print("After append:", my_list)
my_list.remove(2)
print("After remove:", my_list)
```

---

**4. i. Debugging Tools in Python**

**Answer**: Python debugging tools include:


1. **PDB** (Python Debugger)
2. **PyCharm Debugger**
3. **IPython**
4. **Winpdb**
5. **Flake8**

**ii. String Immutability in Python**

**Answer**: Yes. Strings in Python are immutable, meaning once created, they cannot be
modified. Any operation on a string creates a new one.

**iii. Program to Find the Largest of Three Numbers**


```python
a, b, c = 5, 12, 8
largest = max(a, b, c)
print("Largest number is:", largest)
```

---

**5. i. Numeric Types of Data Types**

Answer: **d) All of the mentioned above**

**Justification**: `int`, `float`, and `complex` are all numeric data types in Python.

**ii. Accessing Dictionary Key**

Answer: **b) d["Vaagai"]**

**Justification**: To access a key’s value in a dictionary, use square brackets with the key
name as a string, `d["Vaagai"]`.

You might also like