Day1-Python-Assignment 1.ipynb - Colab
Day1-Python-Assignment 1.ipynb - Colab
ipynb - Colab
x: 10
y: 4.0
z: apple
Type of x: <class 'int'>
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 1/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
Type of y: <class 'float'>
Type of z: <class 'str'>
a: orange
new_list = []
new_tuple = ()
new_set = set()
new_dict = {}
Task: We will be understanding how to work with list, tuple, range and dictionaries.
Steps:
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 2/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
print("Third number:", number_tuple[2]) # Using indexing to access the third element from the tuple.
# Step 3: Try modifying the tuple (uncomment the line below and run it)
# number_tuple[2] = 10
# print(number_tuple)
# tuple can not nbe modified
Second number 4
Third number: 3
1. Start with the dictionary car = {"brand": "Toyota", "model": "Corolla", "year": 2020}.
2. Add a new key-value pair: "color": "red".
3. Update the value of year to 2022.
4. Remove the key model.
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 3/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
Declare variables a = 8 and b = 3 in your code. Perform and print results for the following operations:
Addition
Subtraction
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 4/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
Multiplication
Division
Modulus
Exponentiation
Floor division
Addition (a + b): 11
Subtraction (a - b): 5
Multiplication (a * b): 24
Division (a / b): 2.6666666666666665
Modulus (a % b): 2
Exponentiation (a ** b): 512
Floor Division (a // b): 2
Relational Operators
Is a equal to b? False
Is a not equal to b? True
Is a greater than b? True
Is a less than or equal to b? False
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 5/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
Enter a number: 2
The number is positive and even.
Enter a number: 4
The number is positive.
while(true):
##code to be executed
##exiting the loop.
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 6/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
# Step 1: Input a number
num = int(input("Enter a number: "))
8
10
12
14
16
18
20
0
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
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 7/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
continue
# Execute a code where it prints numbers from 1 to 10 but when we encounter 5 it breaks.
1
2
3
4
5
6
Encountered 7, stopping the loop.
# Code a loop which continues on even numbers and prints odd numbers in the range(0 to 10).
1
2
3
4
6
7
8
9
10
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 8/9
07/02/2025, 19:40 Day1-Python-Assignment 1.ipynb - Colab
https://colab.research.google.com/drive/1_FCK0PBB7xWgcDRuoEla71Yq4D9tgZRp#scrollTo=dRFYs10zvofa&printMode=true 9/9