-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgramming_Assignment_1.py
More file actions
58 lines (41 loc) · 960 Bytes
/
Programming_Assignment_1.py
File metadata and controls
58 lines (41 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
1. Write a Python program to print "Hello Python":
```python
print("Hello Python")
```
2. Write a Python program to do arithmetic operations addition and division:
```python
a = 10
b = 5
addition_result = a + b
division_result = a / b
print("Addition result:", addition_result)
print("Division result:", division_result)
```
3. Write a Python program to find the area of a triangle:
```python
base = 5
height = 8
area = 0.5 * base * height
print("The area of the triangle is:", area)
```
4. Write a Python program to swap two variables:
```python
a = 10
b = 20
print("Before swapping:")
print("a =", a)
print("b =", b)
# Swapping the values
temp = a
a = b
b = temp
print("After swapping:")
print("a =", a)
print("b =", b)
```
5. Write a Python program to generate a random number:
```python
import random
random_number = random.randint(1, 100)
print("Random number:", random_number)
```