Skip to content

Commit 169138d

Browse files
initial commit
0 parents  commit 169138d

File tree

1 file changed

+239
-0
lines changed

1 file changed

+239
-0
lines changed

main.py

+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
2+
# import math
3+
4+
# print("Hello World")
5+
# print(8+4)
6+
# this is singe line comment
7+
8+
''' this is multiline commnent
9+
'''
10+
'''
11+
print(math.gcd(3,6))
12+
print(math.factorial(5))
13+
'''
14+
'''
15+
age=5
16+
17+
if(age>13):
18+
print("Welcome")
19+
else:
20+
print("Hey Kid")
21+
22+
print("Hi")
23+
'''
24+
25+
# a=10
26+
# b="Ashu"
27+
# c=3
28+
29+
# print(a+c)
30+
# print(a-c)
31+
# print(a*c)
32+
# print(a/c)
33+
34+
# 1. variable should start an Underscore Or with letter.
35+
# 2. variable cannot start with number.
36+
# 3. It can only contain alpha numeric (A-Z,a-z,0-9) characters.
37+
# 4. variables names are case senstive.
38+
39+
# print(type(a))
40+
# print(type(b))
41+
42+
# e=int("51")
43+
# print(type(e))
44+
# print(e+8)
45+
46+
# name="Ashu is good boy"
47+
# name='Ashu'
48+
# name='''Ashu
49+
# is a good boy'''
50+
51+
# name="Ashu, samar"
52+
# print(name[2])
53+
# print(name[2:4]) This is called slicing
54+
# print(name)
55+
# print(name.strip()) remove spaces
56+
# print(len(name))
57+
# print(name.lower())
58+
# print(name.upper())
59+
# var=name.replace("As","n")
60+
# print(var)
61+
# print(name.replace(", ", "\n"))
62+
63+
# str1="My Name is "
64+
# str2="Dashminder"
65+
# print(str1+str2)
66+
67+
'''
68+
name1="Ashu"
69+
name2="Samar"
70+
71+
print("This is {1} and He is good boy named {0}".format(name1,name2))
72+
print(f"This is {name2} and he is good named {name1}")
73+
74+
'''
75+
# 1. Exponentiation operator **
76+
# 2. Floor division operator //
77+
# 3. Modulo operator %
78+
79+
'''
80+
a=5
81+
b=2
82+
c=a**b
83+
print(c)
84+
print(a//b)
85+
print(a%b)
86+
'''
87+
88+
# Collections in Python
89+
# 1. List
90+
# 2. Tuple
91+
# 3. Set
92+
# 4. Dictionary
93+
94+
'''
95+
1. List
96+
ls=[19,3,5,8,11,15,25]
97+
# print(ls)
98+
# print(ls[2])
99+
# print(ls[2:4])
100+
ls[2]=48
101+
print(ls)
102+
# ls.append(100)
103+
# ls.insert(4,21)
104+
# ls.remove(19)
105+
# ls.pop() last element remove
106+
# del ls[3]
107+
# ls.clear() empty list
108+
print(ls)
109+
'''
110+
111+
# Tuple
112+
'''
113+
a=("Ashu", "Samar")
114+
# var=type(a)
115+
# print(var)
116+
print(a)
117+
# a[0]="Samy" cannot change
118+
a=list(a)
119+
a[0]="Sunny"
120+
print(a)
121+
'''
122+
123+
# Set
124+
'''
125+
s1={4,3,7,3,3,9,9,9,7,7,4,4,4}
126+
print(s1)
127+
# print(type(s1))
128+
# s1.add(85)
129+
# s1.update([7,8,8,10,10,2,2,2,2,2,2])
130+
# print(len(s1))
131+
# s1.remove(66)
132+
# s1.discard(66)
133+
# s1.clear()
134+
print(s1)
135+
'''
136+
'''
137+
# Dictionary
138+
dict1={"Name":"Ashu",
139+
"Class":"8th",
140+
"Country":"India"
141+
}
142+
print(dict1)
143+
dict1["Country"]="US"
144+
# dict1.pop("Class")
145+
# print(dict1["Country"])
146+
# dict1.update({"Hours":8})
147+
print(dict1)
148+
149+
'''
150+
'''
151+
age=int(input("Enter Age: "))
152+
# print(type(age))
153+
154+
if(age>18):
155+
print("you can drive a car")
156+
elif(age==18):
157+
print("you are an awesome teen")
158+
else:
159+
print("you cannot drive")
160+
'''
161+
162+
# Loops
163+
164+
# for i in range(0,10):
165+
# print(i)
166+
167+
# for i in reversed(range(5+1)):
168+
# print(i, end= " ")
169+
170+
# for i in range(5,0,-1):
171+
# print(i, end= " ")
172+
173+
'''
174+
print("\n")
175+
li=[45, 10, "Hello"]
176+
for i in li:
177+
print(i)
178+
'''
179+
'''
180+
i=5
181+
while(i>0):
182+
print(i)
183+
i=i-1
184+
'''
185+
# Functions
186+
187+
# def greet():
188+
# print("Good Morning Sir")
189+
190+
# greet()
191+
192+
# def Sum(a,b):
193+
# print(a+b)
194+
195+
# Sum(6,7)
196+
'''
197+
def even_odd(n):
198+
199+
if(n%2==0):
200+
return True
201+
else:
202+
return False
203+
204+
N=int(input("Enter a Number: "))
205+
206+
if(even_odd(N)):
207+
print(N,"is Even")
208+
else:
209+
print(N,"is Odd")
210+
211+
'''
212+
'''
213+
class Employee:
214+
215+
def get_data(self,gname,gsalary):
216+
self.name=gname
217+
self.salary=gsalary
218+
219+
def show_data(self):
220+
print("Name:",self.name,"\nSalary:",self.salary)
221+
222+
223+
e1=Employee()
224+
e1.get_data("John Smith",45000.00)
225+
e1.show_data()
226+
'''
227+
228+
class Employee:
229+
230+
def __init__(self,gname,gsalary):
231+
self.name=gname
232+
self.salary=gsalary
233+
234+
235+
e1=Employee("John Smith",45000.00)
236+
print(e1.name,"\n",e1.salary)
237+
238+
239+

0 commit comments

Comments
 (0)