Skip to content

Commit 81232e6

Browse files
committed
python
1 parent c2d077c commit 81232e6

12 files changed

+123
-1
lines changed

__pycache__/harry.cpython-313.pyc

151 Bytes
Binary file not shown.

__pycache__/vishal.cpython-313.pyc

152 Bytes
Binary file not shown.

__pycache__/vishal1.cpython-313.pyc

413 Bytes
Binary file not shown.

day25(shorthand if else).py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
a=13
2+
b=3300
3+
print("A") if a>b else print('=') if a==b else print("-")
4+
5+
# print("Ansh") if a>b else ""
6+
c=9 if a>b else 0
7+
print(c)
8+
9+
10+
# result = value_if_true if condition else value_if_false
11+
# # This syntax is equivalent to the following if-else statement:
12+
13+
# if condition:
14+
# result = value_if_true
15+
# else:
16+
# result = value_if_false

day26(Enumerate Fun).py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
marks=[10,23,27,98,100]
2+
3+
# index=0
4+
# for mark in marks:
5+
# print(mark)
6+
7+
# if(index==3):
8+
# print("Vishal is a Avg student")
9+
# index+=1
10+
11+
#enumerate use in for
12+
for index, mark in enumerate(marks,start=1): #start=1 mtlb ki we decide where to start i.e. indexing
13+
print(mark)
14+
print(index,marks)
15+
16+
if(index==3):
17+
print("Vishal is a Avg student")
18+
#lists
19+
marks=[10,23,27,98,100]
20+
for index,mark in enumerate(marks):
21+
print(index,marks)
22+
# Loop over a tuple and print the index and value of each element
23+
colors = ('red', 'green', 'blue')
24+
for index, color in enumerate(colors): # for color in colours:
25+
print(index, color)
26+
# And here's an example with a string:
27+
28+
# Loop over a string and print the index and value of each character
29+
s = 'hello'
30+
for index, c in enumerate(s):
31+
print(index, c)
32+
33+
fruits = ['apple', 'banana', 'mango']
34+
for index, fruit in enumerate(fruits):
35+
print(f'{index+1}: {fruit}')
36+
# The enumerate function is often used when you need to loop over a sequence and
37+
# perform some action with both the index and value of each element. For example-
38+
# you might use it to loop over a list of strings and print the index and
39+
# value of each string .

day27(import works).py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
3+
# # import math
4+
# # math.floor(4.5668)
5+
# import math
6+
7+
# result = math.sqrt(9)
8+
# print(result) # Output: 3.0
9+
10+
# from math import sqrt,pi
11+
# result=sqrt(9)*pi
12+
# print(result)
13+
14+
# from math import * # isse sb module ho jayega import
15+
# from math import sqrt as s # isse wo module ka shortcut aur descriptive hi jayega
16+
17+
18+
# #to print the all libraires of module
19+
import vishal as vs
20+
import math
21+
22+
print(dir(math))
23+
print(math.nan ,type(math.nan) )
24+
vs.welcome()
25+
print(vs.vishal)

day28(os module).py

Whitespace-only changes.

day29(Local & Global Varibale).py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# x=4
2+
# print(x)
3+
4+
5+
# def hello():
6+
# x=5
7+
# print(f"the local varibale is :{x}")
8+
# print("hello vs code ")
9+
# print(f"the global varibale is {x}")
10+
# hello()
11+
# x=5
12+
# print(f"the global variable is {x}")
13+
14+
x = 10 # global variable
15+
16+
17+
def my_function():
18+
global x
19+
x = 5 # this will change the value of the global variable x
20+
y = 5 # local variable
21+
22+
23+
my_function()
24+
print(x) # prints 5
25+
print(y) # this will cause an error because y is a local variable and
26+
# is not accessible outside of the function

ex-4 (Secret code).py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def encode(word):
2727
if len(word) < 3:
2828
return word[::-1] # Reverse the word but -1 HELLO _1,-1 krte krte o,l,l,e,h
2929
else:
30-
return "abc" + word[1:] + word[0] + "xyz" # Modify the word
30+
return "abc" + word[1:] + word[0]+ "xyz" # Modify the word
3131

3232
def decode(word):
3333
if len(word) < 3:

main.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import vishal1
2+
3+
vishal1.welcome() # yha pe do baar print ho ja rha h if __name__ == "__main__": ye use karenge us module me vishal1
4+
# top do baar prnt nhi hoga

vishal.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def welcome():
2+
print("Hey you are welcome my friend")
3+
4+
5+
vishal = "A good boy"

vishal1.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def welcome():
2+
print("Hey you are welcome from vishal")
3+
4+
print(__name__)
5+
6+
if __name__ == "__main__":
7+
welcome()

0 commit comments

Comments
 (0)