Skip to content

Commit 16e8dec

Browse files
committed
Python
1 parent b3b2a52 commit 16e8dec

11 files changed

+108
-0
lines changed

Mad lib game.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
color=input("Enter the color:")
2+
Plural_noun=input("Enter the plural_noun:")
3+
celeb=input("Enter the celeb:")
4+
5+
6+
print("roses are"+ color)
7+
print(Plural_noun + "is blue")
8+
print("i love" +celeb)
File renamed without changes.

day11(Functions).py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def calculateGmean(a, b):
2+
mean = (a*b)/(a+b)
3+
print(mean)
4+
5+
def isGreater(a, b):
6+
if(a>b):
7+
print("First number is greater")
8+
else:
9+
print("Second number is greater or equal")
10+
11+
def isLesser(a, b):
12+
pass
13+
14+
15+
a = 9
16+
b = 8
17+
isGreater(a, b)
18+
calculateGmean(a, b)
19+
# gmean1 = (a*b)/(a+b)
20+
# print(gmean1)
21+
c = 8
22+
d = 74
23+
isGreater(c, d)
24+
calculateGmean(c, d)
25+
# gmean2 = (c*d)/(c+d)
26+
# print(gmean2)

day12(Arguments).py

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Default Arguments
2+
# Keyword Arguments
3+
# Variable length Arguments
4+
# Required Arguments
5+
# def Average(a,b):
6+
# print("Avergae of two numbers",(a+b)/2)
7+
# Average(2,5)
8+
9+
def average(*numbers):
10+
# print(type(numbers))
11+
sum = 0
12+
for i in numbers:
13+
sum = sum + i
14+
# print("Average is: ", sum / len(numbers))
15+
# return 7
16+
return sum / len(numbers)
17+
18+
19+
# average(4, 6)
20+
# average(b=9)
21+
22+
c = average(5, 6, 7, 1)
23+
print(c)

day13 (Lists).py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# LISTS
2+
l=[2,4,6,"Vishal","10Aug"]
3+
print(l)
4+
print(type(l))
5+
print(l[3])
6+
print(l[-2]) #this means ----- marks(l[len(l)-2])
7+
8+
#[:] mtlb [0:len(l)]
9+
print(l[:]) # issee pura cheez print hoga isko STRING SLICING bolte h and [[1:]] to 1 se shuru hoga nd n-1 tk jayega
10+
print(l[1:4:2]) # last wla JUMP WLA H 2 2 jump karega
11+
if 0 in l: #agar yhi pr "0" aise 0 ko likhenge to result no aayega coz wo int h na ki string
12+
print("yes present")
13+
else:
14+
print("No absent")
15+
16+
if "ug" in "10Aug": #simpe if __in__: same chhez appply for string🚀
17+
print("Yes")
18+
else:
19+
print("NO")
20+
21+
#LIST COMPRESHENSION
22+
23+
lst = [i*i for i in range(10)]
24+
print(lst)
25+
lst = [i*i for i in range(10) if i%2==1]
26+
print(lst)
27+
28+
#LIST METHOD
29+
L=[23,45,87,32,0,65]
30+
print(L)
31+
L.append(98)
32+
print(L)
33+
L.sort()# defalut ascending orer me hoga
34+
print(L)
35+
L.sort(reverse=True) # desc me order me print kar dega
36+
print(L)
37+
L.reverse()
38+
print(L) #reverse kr deta h
39+
print(L.index(65)) #index dega
40+
print(L.count(65)) #count karega
41+
m=l.copy() #m=l v kr skte the but we r beginners so use copy method as shown
42+
m[0]=2
43+
print(L)
44+
L.insert(1,899) # ye us inderx pe ja ke wo valuve inset kr dega
45+
print(L)
46+
m = [900, 1000, 1100] # koi aur m naam ka list h
47+
l.extend(m) # iska mtlb l ko kholo nd ye m list ka vlaue enter kra do
48+
49+
50+
k=l+m # naya list hi bna do do lsit ko concatenate kr ke
51+
print(k)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)