Skip to content

Commit ce5c2ef

Browse files
authored
Added Python Basics and List & Tuple
0 parents  commit ce5c2ef

24 files changed

Lines changed: 843 additions & 0 deletions
1.52 MB
Loading
1.52 MB
Loading
1.6 MB
Loading
2.07 MB
Loading
1.32 MB
Loading

DAY_2/variables.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
x = 400
2+
y = 400
3+
4+
print()
5+
print('x : ',id(x))
6+
print('y : ',id(y))
7+
8+
a = 100
9+
b = 100
10+
11+
print()
12+
print('a : ',id(a))
13+
print('b : ',id(b))
14+
15+
name = "Ashish!"
16+
other_name = "Ashish!"
17+
18+
print()
19+
print('name : ',id(name))
20+
print('other_name : ',id(other_name))
21+
22+
fval = 4.34
23+
other_fval = 4.34
24+
25+
print()
26+
print('fval : ',id(fval))
27+
print('other_fval : ',id(other_fval))
28+
29+
1.33 MB
Loading
1.23 MB
Loading
1.47 MB
Loading

DAY_3/strings.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Python supports only single line comment
2+
3+
str_single_quote = "Python" # single quote
4+
str_double_quote = 'Python' # double quote
5+
str_multi_line = '''
6+
Hello,
7+
This is multi line string
8+
'''
9+
10+
print(str_single_quote)
11+
print(str_double_quote)
12+
print(str_multi_line)
13+
14+
print(40 * "=")
15+
16+
# Indexing start from 0
17+
# In python we have positive indexing from 0 and negative indexing from -1
18+
19+
print(str_single_quote[1])
20+
print(str_single_quote[-1])
21+
22+
print(40 * "=")
23+
24+
# why both str_double_quote and str_double_quote[0] addresses are different ?
25+
# Ans : Due to different strings they have different memory addresses.
26+
27+
print(id(str_double_quote))
28+
print(id(str_double_quote[0]))
29+
30+
print(40 * "=")
31+
32+
str1 = 'Fynd'
33+
print(str1 + ' :' ,id(str1))
34+
print(str1[0] + ' :' ,id(str1[0]))
35+
print(str1[1] + ' :' ,id(str1[1]))
36+
print(str1[2] + ' :' ,id(str1[2]))
37+
print(str1[3] + ' :' ,id(str1[3]))
38+
39+
print(40 * "=")
40+
41+
# slicing
42+
str_new = "SLICING"
43+
print(str_new[:])
44+
print(str_new[2:])
45+
print(str_new[2:5])
46+
print(str_new[::-1])
47+
print(str_new[:5:2])
48+
49+
print(40 * "=")
50+
51+
52+
# functions
53+
print(len(str_new)) # here len is function
54+
print(str_new.count('I')) # str_new is reference variable and count is method
55+
56+
print(40 * "=")
57+
58+
59+
60+

0 commit comments

Comments
 (0)