8000 push · chandantech56/python-class@ea2172d · GitHub
[go: up one dir, main page]

Skip to content

Commit ea2172d

Browse files
committed
push
1 parent c95a1d3 commit ea2172d

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed

python_class10/class10.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
student.remove("rahul")
2121
print(student)
2222

23-
#clear : this methods use clear the entire values.
23+
#clear : this methods use clear the entire values. print empty set ()
2424
student.clear()
2525
print(student)
2626
#union methods in set
@@ -44,10 +44,11 @@
4444
print("you are pass")
4545
else:
4646
print("you are faild")
47+
4748
#program for driving pass age
4849
age = int(input("enter your age: "))
4950
if age>=18:
50-
print(f"you are {age} years old, so you are eligible for drive")
51+
print(f"your {age} years old, so you are eligible for drive")
5152
elif age<18:
5253
print(f"your age is {age}.so you are not eligible for drive")
5354
elif age >=60:

python_class11/class11.py

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# ---------FOR LOOP---------------
2+
# The for loop in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects.
3+
for i in range(10):
4+
print(i)
5+
#print table using for loop
6+
number= int(input("Enter the number"))
7+
for count in range(1,11):
8+
table= number*count
9+
print(number, "x" , count, "=", table)
10+
# #----------------------------------------
11+
for i in range(1,50):
12+
print(i)
13+
14+
# --------WHILE LOOP-------------------
15+
#Python while loop: The while loop in Python is used to iterate over a block of code as long as the test expression (condition) is true.
16+
count=0
17+
while count<=4:
18+
print("hello, im a while loop") #print unfinite bcz not given stop...
19+
count= count+1
20+
21+
# #print table using while loop
22+
number= int(input("Enter the number"))
23+
count=1
24+
while count<=10:
25+
table= number*count
26+
print(number, "x", count, "=", table)
27+
count = count+1
28+
29+
#print table in reverse using while loop
30+
number= int(input("Enter the number"))
31+
count=10
32+
while count>=1:
33+
table= number*count
34+
print(number, "x", count, "=", table)
35+
count = count-1
36+
37+
# Python break and continue Statement:
38+
for i in range(1,6):
39+
print(i)
40+
41+
for i in range(1,6):
42+
print(i)
43+
break
44+
45+
for i in range(1,5):
46+
if i==3:
47+
break
48+
print(i)
49+
print("the end")
50+
51+
for i in range(5):
52+
number= float(input("enter the number: "))
53+
if number<0:
54+
continue
55+
print(number)
56+
57+
#Pass Statement: pass statement is a null statement.
58+
number=5
59+
if number>0:
60+
pass
61+
62+
63+
#---------FUNCTION------------
64+
# Functions: A function is a group of related statements that performs a specific task.
65+
# * functions help break our program into smaller and modular chunks. As our program grows
66+
# * larger and larger, functions make it more organized and manageable.
67+
# * It avoids repetition and makes the code reusable.
68+
69+
def greet():
70+
print("hello")
71+
print("how are you")
72+
greet()
73+
74+
#print greet values 3 times (again again)
75+
def greet():
76+
print("hello")
77+
print("how are you")
78+
greet()
79+
greet()
80+
greet()
81+
82+
#add function
83+
def add(a,b):
84+
c = a+b
85+
print("The result of c is: ", c)
86+
add(20,30) #output 50
87+
88+
# Calculatong factorial in function
89+
def factorial(n): #"""Return the factorial of a number."""
90+
if n == 0:
91+
return 1
92+
else:
93+
return n * factorial(n - 1)
94+
95+
print(factorial(5)) # Output: 120
96+
97+
98+
# Lambda Functions: In Python, an anonymous function is a function that is defined without a name.
99+
add=lambda a,b:a+b
100+
print(add(10,20)) #output 30

0 commit comments

Comments
 (0)
0