Skip to content

Commit 2169762

Browse files
Add files via upload
1 parent 4e273cb commit 2169762

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+12705
-0
lines changed

!Chhoti-Chhoti Magar Motii Baate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Equal to Equal to Operator( == ) or Comparision Operator compare the "Values" while identity operator( is,isnot ) compare the "MEMORY ALLOCATION" and since "list" is "MUTTABLE DATATYPE" which stores different values at different memorry allocation that's it's showing "FALSE"
2+
# ord command is basically uses for converting the alphabetical charatcer into ASCII value
3+
#chr is a command which is uses for geting the ALPHABETICAL CHARACTER Sfrom entered ascii Value
4+
# pip freeze is a command by which i can get all the installed libraries in system and check that whichever is installed or not..
5+

10.assignment.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#Qun:- 1) write a python programe to find those numbers which are divisible by 7 and 5, between 1500 and 2700 (both included)
2+
# 2) Write a python program to count the number of even and odd numbers from a series of numbers.
3+
# 3) Write a python program which iterates the integers from 1 to 50. For multiples of three print "Fizz" instead of the numbers and for the multiples of five print "Buzz". For numbers which are multiples of three and five both print "FizzBuzz"?
4+
# 4) Write a pyrhon program to calculate the sum and average of n integer numbers>
5+
# 5) Write a python program to calculate factorial of a number?
6+
7+
8+

11 - Strings in Python.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Strings in Python Programming:-
2+
"""
3+
1) Strings are Immutable
4+
2) String is ordered data structure and supports to indexing & Slicing
5+
"""
6+
s = "python"
7+
print(type(s))
8+
print(id(s))
9+
print(s)
10+
11+
s = "java"
12+
print(type(s))
13+
print(id(s))
14+
print(s)
15+
16+
d = "python"
17+
print(type(d))
18+
print(id(d))
19+
print(d)
20+
21+
#indexing:- in this there are two categories:-1){Left Hand Side Indexing}:- In which indexing startted from left to right [ Where we start counting from indxing 0 ]
22+
# 2){Right to Left Indexing} :- In which indexing started from right to left [ Where we count from -1 ]
23+
24+
s = "Python Sample String"
25+
print(s[0])#p
26+
print(s[-1])#g
27+
print(s[1])#y
28+
print(s[-2])#n
29+
30+
#Slicing:-
31+
s = "Python Sample String"
32+
print(s[0:5])#Pytho
33+
print(s[0:6])#Python
34+
print(s[7:])#Sample String (Started from 7 that is s of string and end is not mentioned so printed till last)
35+
print(s[ :6])#Python (Since Start point is not mentioned so starting form zero by default)
36+
37+
38+
#Stride:- is uses for printing of selected letters
39+
# If the stride is possitive[+] it will give direction from left to right, negative[-] it will give direction from right to left
40+
print(s[ : :2])#Pto apeSrn (I do not want initialize:do not want to print end:but print every second letter)
41+
print(s[ : :3])#Ph metn (after 1st lettere[P] every third letter will be print)
42+
43+
print(s[ : :-1])#gnirtS elpmaS nohtyP ( negative indexing prints from right hand side, so in stride prints reversely )
44+
print(s[ : :-2])#git lmSnhy ( after last first element it will print every second element from last )
45+
46+
47+
# For printing ewvery letter of memtiones string
48+
for value in s:
49+
print(value)
50+
"""P
51+
y
52+
t
53+
h
54+
o
55+
n
56+
57+
S
58+
a
59+
m
60+
p
61+
l
62+
e
63+
64+
S
65+
t
66+
r
67+
i
68+
n
69+
g """
70+
71+
# in such a way for iterating characters:-
72+
for value in s[ : :2]:
73+
print(value)
74+
"""P
75+
t
76+
o
77+
78+
a
79+
p
80+
e
81+
S
82+
r
83+
n"""
84+
85+
help(str)
86+
87+
88+
89+
90+
91+
92+
93+

12 - String & Built - in Function.py

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#Str Datatypes buit-in functions:-
2+
#Use of format
3+
num1 = 200
4+
num2 = 500
5+
print("Value of num1 is:- ",num1,"And the value of num2 is:- ",num2)
6+
print("value of num1 is - {} and the value of num2 is - {}".format(num1,num2))#value of num1 is - 200 and num2 is 500
7+
print("value of num1 is - {0} and num2 is {1}".format(num1,num2))#value of num1 is - 200 and num2 is 500
8+
#There is indexing for both the values for first value indexing is (0) and for second value indexing is (1)
9+
print("value of num1 is - {1} and num2 is {0}".format(num1,num2))#value of num1 is - 500 and num2 is 200
10+
#it has just reversed the values duw to reverse the indexing
11+
print("value of num1 is:- {val1} and the value of num2 is:- {val2}".format(val1=num1,val2=num2))#value of num1 is:- 200 and the value of num2 is:- 500
12+
13+
14+
s = "python sample string"
15+
print(s)#python sample strin
16+
print(id(s))#52795072
17+
s = s.capitalize()
18+
print(s)#Python sample string
19+
print(id(s))#52852736
20+
#So we are assigning the same variable name but internally stored at different memory location because strings are immutable
21+
print(s.upper())#PYTHON SAMPLE STRING
22+
print(s.lower())#python sample string
23+
print(s.title())#Python Sample String
24+
25+
26+
#Buit in functions in python programming:-
27+
#it gives the output in terms of "TRUE" ot "FALSE"
28+
#Standard Fomat may be expressed as - print(variable.istask())
29+
s = "python sample string"
30+
print(s.isupper())#False
31+
s = s.upper()
32+
print(s.isupper())#True
33+
print(s.islower())#False
34+
s = s.lower()
35+
print(s.islower())#True
36+
print(s.istitle())#False
37+
s = s.title()
38+
print(s.istitle())#True
39+
40+
#Spli & Join function in Pyhton programming:-
41+
s = "HTML,CSS,PYTHON,JAVA,JAVASCRIPT,DJANGO"
42+
l = s.split(",")
43+
print(l)#['HTML', 'CSS', 'PYTHON', 'JAVA', 'JAVASCRIPT', 'DJANGO']
44+
l = s.split(" ")
45+
print(l)#['HTML,CSS,PYTHON,JAVA,JAVASCRIPT,DJANGO']
46+
s1 = (" ").join(l)
47+
print(s1)
48+
49+
#Use of Maketrans and Translate Function:-
50+
s1 = "abcd"
51+
s2 = "1234"
52+
s3 = "Python Sample String abcd"
53+
table = str.maketrans(s1,s2)
54+
result = s3.translate(table)
55+
print(result)#Python S1mple String 1234z
56+
57+
#find,index and rfind function:-
58+
s = "HTML,CSS,PYTHON"
59+
print("PYTHON" in s)#True
60+
print(s.index("PYTHON"))#9
61+
# it is case sensitive, if i write python at the place of PYTHON it showsme some error
62+
#in case of multiple occurance of PYTHON it will count indexing for first one and return
63+
s = "HTML,CSS,PYTHON,PYTHON,PYTHON"
64+
print("PYTHON" in s)
65+
print(s.index("PYTHON"))#9
66+
#find also start indexxing from left to right
67+
print(s.find("PYTHON"))#9
68+
#but in case of case sensitiveness, it will shows -1
69+
print(s.find("python"))#-1
70+
# This is the only difference betwen find and index functions that in case of(case sensitivenss) in index function it shoes "ERROR" but in find it shoes "-1".
71+
s = "HTML,CSS,PYTHON,PYTHON,PYTHON"
72+
print("PYTHON" in s)
73+
print(s.rfind("PYTHON"))#23
74+
#r.find also uses for indexing but start from Right to Left
75+
76+
77+
#USe of Strip Function:-
78+
#it is uses for removing spacing inside the string or any other special character inside the string
79+
s = " This is sample string "
80+
s1 = s.strip(" ")
81+
print(s1)#This is sample string
82+
s = "*******************This is sample string*********"
83+
s1 = s.strip("*")
84+
print(s1)#This is sample string
85+
s1 = s.lstrip("*")
86+
print(s1)#This is sample string*********
87+
#lstrip is uses for removing the space,star or any special character from left hand side and similarly for Right Hand Side rstrip
88+
s1 = s.rstrip("*")
89+
print(s1)#*******************This is sample string
90+
91+
92+
#Center and Left Right Moving Sting with Special Charcater or Space Functions
93+
s = "python"
94+
s1 = s.center(20,"*")
95+
print(s1)#*******python******* ( by uing center we can print string word in center and apply selected special character and space around left & right)
96+
s1 = s.ljust(20,"*")
97+
print(s1)#python************** ( by uing ljust we can print string word in Left hand side )
98+
s1 = s.rjust(20,"*")
99+
print(s1)#**************python ( by uing rjust we can print string word in Right hand side )
100+
s1 = s.center(100,"#")
101+
print(s1)################################################python###############################################
102+
103+
#Replace Function:-
104+
s = "html,css,python,java,html"
105+
s1 = s.replace("html","HTML5")
106+
print(s1)#HTML5,css,python,java,HTML5
107+
s1 = s.replace("java","JAVASCRIPT")
108+
print(s1)#html,css,python,JAVASCRIPT,html
109+
110+
print(dir(str))
111+
help(str)
112+
113+
114+
115+
116+
117+
118+
119+
120+
121+
122+
123+
124+
125+
126+
127+
128+
129+
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
140+
141+
142+
143+
144+

13 - List.py

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#List Datatype, Indexing, Slicing,Append-Insert-Extend:-
2+
"""
3+
List is a datatype in which we can sotre the data,everything which is inside square brackets[] is list
4+
# Python list is HETROGENEOUS in which i can store different type of data it may be int,float as well as string
5+
#Python list is a "MUTTABLE" datatype in which i can add,update and delete the stored data at the same memory location means id dosnt't change while remaining same
6+
1) List are Muttable we can add,Update,Delete
7+
2) Ordered Datatype means includes Indexing & Slicing
8+
3) It is a Hetrogeneous Datatype, I can store any time of Data inside it
9+
10+
"""
11+
l = [10,20,30,40,"Python","Java",[100,200,300]]
12+
print(l,type(l))
13+
14+
15+
#Indexing:-
16+
print(l[0])#10
17+
print(l[5])#Java
18+
print(l[-1])#[100, 200, 300]
19+
print(l[-1][0])#100
20+
"""print(l[20])"""#list index out of range
21+
22+
23+
#slicing:-
24+
print(l[1:3])#[20, 30]
25+
#at place of 3 here is 40 which si not inclusive
26+
print(l[ : : -1])#[[100, 200, 300], 'Java', 'Python', 40, 30, 20, 10] ( IT reveerse the list )
27+
28+
29+
l = [100,200,300,400,500]
30+
for value in l:
31+
print(value)
32+
"""
33+
100
34+
200
35+
300
36+
400
37+
500"""
38+
# On each iteration we get on element from this list, whenever we iterating over list we iterarating over elements while in terms of string we iterating over characters
39+
for value in l[ : :2]:
40+
print(value)
41+
"""
42+
100
43+
300
44+
500 """
45+
46+
#Methods for inserting a new element in list:-
47+
l = [100,200,300,400,500]
48+
print(id(l))#44193928
49+
l.append(600)
50+
print(l)#l = [100,200,300,400,500,600]
51+
print(id(l))#44193928
52+
#Since id of list after adding an element is also remaining same bacause List are MUTTABLE at same memory location we are modifying the values
53+
num1 = 100
54+
print(id(num1))#8791238282608
55+
print(id(l[0]))#8791238282608( So both the id's( Memory Locations ) are exact similar bacause list stores the refenrence of values
56+
57+
58+
#Methods for adding multiple elements in list:- 1) Extend & Append Method:-
59+
l = [100,200,300,400,500]
60+
l.extend([500,600,700,800])
61+
print(l)#[100, 200, 300, 400, 500, 500, 600, 700, 800]
62+
l.append([500,600,700,800])
63+
print(l)#[100, 200, 300, 400, 500, 500, 600, 700, 800, [500, 600, 700, 800]]
64+
#So this is the deifference between extend and append that in case of APPEND it add as "[ONE ELEMENT]" in list while in case of EXTEND it adds all as "[INDIVIDuAL]"[ELEMENTS]"
65+
#l.extend([500,600,700,800],100,200)#extend() takes exactly one argument (3 given)
66+
#l.append([500,600,700,800],100,200)#append() takes exactly one argument (3 given)
67+
#So in both we can add only one arguement
68+
l.extend("Python")
69+
print(l)#[100, 200, 300, 400, 500, 500, 600, 700, 800, [500, 600, 700, 800], 'P', 'y', 't', 'h', 'o', 'n']
70+
#it will iterating over character by character over the string
71+
72+
""" 2) By Insert Method:-"""
73+
l = [100,200,300,400,500]
74+
l.insert(1,1000)
75+
print(l)#[100, 1000, 200, 300, 400, 500]
76+
#by insert method it add element on index plce
77+
#by insert method we can add ONLY ONE element not more than one
78+
l = [10,20,30]
79+
l2 = l
80+
print(id(l),id(l2))#50708616 50708616
81+
print(l,l2)#[10, 20, 30] [10, 20, 30]
82+
#Many time there is a need for copy content from one list to another list, there is no change in Memory Allocation
83+
l.append(40)
84+
print(l,l2)#[10, 20, 30, 40] [10, 20, 30, 40]
85+
print(id(l),id(l2))#51408456 51408456
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
113+
114+
115+
116+

0 commit comments

Comments
 (0)