- write
warning β οΈ which can overwrite if there is something inside file
f = open('file.txt','w')
f.write(newline)
f.close()
-append can we use if want to add in the file something in the end use "a"
f = open('file.txt','a')
Day 18 Python Learning
read and write file in python :
\- read file (1st option not recommended need to close every time)
f = open('filename.txt')
data = https://t.co/zyEVe14gHA()
print(data)
f.close()
option 2 - automatically close when use
\- with statement
it much better and clean
with open('python\_4\_4\_file/my\_17.1.txt') as f: print(https://t.co/zyEVe14gHA())
and like __init__ the Construction type there is more
- dunder method which used for to tell Python what to do
like __add__ Arithmetic type for +
same __sub__, __mul__, __truediv__, __pow__, etc. + r versions (__radd__) and more
#python#coding#ai#codingsect
Day 17 Python Learning
practicing class & dunder method
if follow my previous day note then most of my brother & sister already know what is the class
class work like local apartment which have different room called function use __init__() to connect outside world
Day 16 Python Learning
decorators & operation overload
- decorators
@classmetho use when we want to directly show / use class attribute not instance attribute
@properties use for read only and hide complexity
@setter use for show thing need to or user want to show not all
- multi-level inheritance where 2nd class in Heritage from 1st class ,3th inherited from 2nd & go on like family chain
solve some list comprehensive easy problem
#python#coding#ai
Day 14 Python Learning
late update thanks to Black out
yesterday learning was
- inheritance (parent - child method)
when the new class in Heritage from existing class like the same function why writer when it's exist just take it
- multi inherities
Day 13 Python Learning
was thinking about inherities to but
after opening hacker rank I was busy doing some solution
but it's not a way I learn
\- list comprehensive
\-and just now the class practice little Messy but did it
#python#coding#ai#codingsect
Day 12 Python Learning
try to make password strength checker with only
- while
- for with any
- if & else
and OOP class exercise
#python#coding#ai#codingsect
-__init__
use to connect line with self can take many argument in place of default class
""" it may same confusing but it clear and easy """
just when writing in the beginning you may face error
#python#coding#ai
Day 11 Python Learning
finally time of class not school class
class in python:
- class is blueprint map in simple world which help you to know and create,control,manage what,where,why you want
- self in class
it used for read and change(overwrite)