Skip to content

Commit 0efbc61

Browse files
committed
python
1 parent 81232e6 commit 0efbc61

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

day29(Local & Global Varibale).py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ def my_function():
2222

2323
my_function()
2424
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
25+
#print(y) # this will cause an error because y is a local variable and
26+
# is not accessible outside of the function

day30(File IO).py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#READING A FILE
2+
3+
# f = open('myfile.txt','r') # r - read w-write a-append
4+
# # if w mode me aise file ko khol diya jo exist nhi krta then
5+
# # naya file bn ke aa jaeyga
6+
# # # print(f)
7+
# text = f.read()
8+
# print(text)
9+
# f.close()
10+
11+
# WRITING A FILE
12+
f=open('myfile.txt', 'a')
13+
f.write('Hello, world!')
14+
f.close() # yha pe close krna pdta g har samay buut using WITH no need to close
15+
16+
with open('myfile.txt','a') as f:
17+
f.write("hey i mm inside the environment")

myfile.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
I am a good guy pursuing B-Tech from KIIT university
2+
Hello, world!Hello, world!Hello, world!hey i mm inside the environmentHello, world!hey i mm inside the environment

myfile2.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)