In [4]:
seq = [1,2,3,4,5]
for items in seq:
    print(items)


1
2
3
4
5

In [5]:
names_list = ["shashank","Abhinav","Nisha","Shruthi"]
for names in names_list:
    print(names)


shashank
Abhinav
Nisha
Shruthi

In [7]:
i = 1
while i<10:
    print("The value of i is {}".format(i))
    i = i+1


The value of i is 1
The value of i is 2
The value of i is 3
The value of i is 4
The value of i is 5
The value of i is 6
The value of i is 7
The value of i is 8
The value of i is 9

In [12]:
range(1,25)
for item in range:
    print('This is the {} value is the range'.format(item))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-6949e30bae3f> in <module>()
      1 range(1,25)
----> 2 for item in range:
      3     print('This is the {} value is the range'.format(item))

TypeError: 'type' object is not iterable

In [11]:
#range(0,25)
for item in range(0,25):
    print('This is the {} value is the range'.format(item))


This is the 0 value is the range
This is the 1 value is the range
This is the 2 value is the range
This is the 3 value is the range
This is the 4 value is the range
This is the 5 value is the range
This is the 6 value is the range
This is the 7 value is the range
This is the 8 value is the range
This is the 9 value is the range
This is the 10 value is the range
This is the 11 value is the range
This is the 12 value is the range
This is the 13 value is the range
This is the 14 value is the range
This is the 15 value is the range
This is the 16 value is the range
This is the 17 value is the range
This is the 18 value is the range
This is the 19 value is the range
This is the 20 value is the range
This is the 21 value is the range
This is the 22 value is the range
This is the 23 value is the range
This is the 24 value is the range

In [14]:
list = range(25,50)
for item in list:
    print('The list item number is {}'.format(item))
    
list


The list item number is 25
The list item number is 26
The list item number is 27
The list item number is 28
The list item number is 29
The list item number is 30
The list item number is 31
The list item number is 32
The list item number is 33
The list item number is 34
The list item number is 35
The list item number is 36
The list item number is 37
The list item number is 38
The list item number is 39
The list item number is 40
The list item number is 41
The list item number is 42
The list item number is 43
The list item number is 44
The list item number is 45
The list item number is 46
The list item number is 47
The list item number is 48
The list item number is 49
Out[14]:
range(25, 50)

In [15]:
list


Out[15]:
range(25, 50)

In [17]:
range(1,25)


Out[17]:
range(1, 25)

In [19]:
list(range(5))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-4cacfcabd565> in <module>()
----> 1 list(range(5))

TypeError: 'range' object is not callable

In [20]:
list(range(5))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-20-4cacfcabd565> in <module>()
----> 1 list(range(5))

TypeError: 'range' object is not callable

In [21]:
list(range(5))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-21-4cacfcabd565> in <module>()
----> 1 list(range(5))

TypeError: 'range' object is not callable

In [25]:
mylist = range(1,11)

In [27]:
mylist


Out[27]:
range(1, 11)

In [26]:
for item in mylist:
    print(item)


1
2
3
4
5
6
7
8
9
10

In [29]:
for item in range(0,101):
    print(item)


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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

In [56]:
def printName(name,lastname):
    """
    This is a sample function
    so this is just here for no reason
    """
    print(name + " " +lastname)
    sum = 10+5
    print(sum)
    print("The name is {} {}".format(name,lastname))

In [55]:
printName("shashank","ragireddy")


shashank ragireddy
15
The name is shashank ragireddy

In [74]:
seq = [1,2,3,4,5]
for item in seq:
    print(item)


1
2
3
4
5

In [69]:
def times2(num):
    return num*2

In [70]:
times2(3)


Out[70]:
6

In [71]:
map(square,seq)


Out[71]:
<map at 0x104b4f5c0>

In [73]:
list(map(times2,seq))


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-73-32d254327b69> in <module>()
----> 1 list(map(times2,seq))

TypeError: 'range' object is not callable

In [ ]: