-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapter4.py
73 lines (59 loc) · 1.4 KB
/
chapter4.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Chapter 4 _ Working With Lists
## Looping Through an Entire List
# Life=["child",'student','job holder','marry','children','death']
# for value in Life:
# print("man is " + value)
## Doing Something After a for Loop
# for value in Life:
# print(value.title() + ", Nothing to say!")
# print("What can i do, " + value.title() + ".\n")
## Making Numerical Lists (Using the range() Function)
# for i in range(1,11):
# print(i)
## Making Numerical Lists (Using range() to Make a List of Numbers)
# mehedi=list(range(1,10))
# hasan=mehedi
# print(hasan)
# print(mehedi)
# even_number = list(range(2,11,2))
# print(even_number)
# odd_number = list(range(1,11,2))
# print(odd_number)
# listf=[1,2,3,4,5,6,7,8]
# v=listf
# print(v)
# squire=[]
# for i in range(1,11):
# squire.append(i**2)
# print(squire)
# squires=[]
# for i in range(1,11):
# squire = i**2
# squires.append(squire)
# print(squires)
# m1=[1,2,3,4,5,6]
# v=m1
# print(v)
## Tuples
# Introduction of Tuple
# b=10
# print(b)
# b=11
# print(b)
# jhapsha = (50,250,450)
# print(jhapsha[2])
# print(jhapsha[0])
## Looping Through All Values in a Tuple
# money = (1,2,5,10,20,50,100,500,1000)
# for i in money:
# print(i)
## Writing over a Tuple
# price = (500,1250)
# print("Original price:")
# for value in price:
# print(value)
#
# price = (1000,2500)
# print("\nModified price:")
# for value in price:
# print(value)