Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

Python Notes

This document provides comprehensive notes on Python coding, covering data types, comments, operators, and control structures. It explains concepts such as lists, tuples, dictionaries, loops, and functions, along with their syntax and usage. Additionally, it highlights important programming principles like immutability, nesting, and the distinction between built-in and user-defined functions.

Uploaded by

stonecoldak0723
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python Notes

This document provides comprehensive notes on Python coding, covering data types, comments, operators, and control structures. It explains concepts such as lists, tuples, dictionaries, loops, and functions, along with their syntax and usage. Additionally, it highlights important programming principles like immutability, nesting, and the distinction between built-in and user-defined functions.

Uploaded by

stonecoldak0723
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

# Python coding notes :

1. data type :

> integers ( +ve / -ve / 0 )


> string ( koi bhi sentence double single & triple quote me ho )
> float ( number me hi decimal values )
> boolean ( aisa type jisme value ya toh True hai ya False ) - yaad rhe isme t and
f capital rhe humesha .
> None ( aisa type jidr value none ho ) for eg - a = none ( here n bhi capital
rhega nhi toh error aa jayega )

2. Comments in python . ( kuch bhi comment likhna jo run nhi krega )

> # single line comments ( ctrl + / se # aa jayega )

> """ multiline commments """

3. Type of operators

> arithematic operators :

+ ( sum )
- ( difference )
* ( multiply krna )
/ ( divison )
% ( remander nikalna ) - modulo bolte hai ise
** ( power operator ) eg ( a**b so a^b )

> Rational operators :

== ( equals to ) in python eg ( a==b)


!= ( not equals to )
> ( greater than )
< ( less than )
>= ( greater than and equals to )
<= ( less than and equals to )

in sb ka data type boolean hota hai and last ke jo do hai usme agr ek bhi sahi hua
toh code true hoga jb run krenge .

> Assignment operators :

= ( equals to ) eg a= 20
+= ( plus equals to )
-= ( minus " )
*= ( multiply " )
/= ( divide " )
%= ( remainder " )
**= ( power " )

2nd se lekr last tk in sb me ye hota hai do values hongi unke sath operations kro )
same naam ki
eg for += : Num = 20

Num = 20 + Num ( this is Num+= ) ye likho or run kro toh value 40


aayegi .

eg for ** : num = 3

: num = 6

( num**= )

print("num":, num )

ans = num: 729

> logical operators :

ye boolean type hote hai and boolean values hi dete hai

1st) not ( agr true & false ke aage not lga denge toh uski opposite value dega ) ye
single value pe kaam krta h )

not T = False
not F = True

2nd) and ( do values pe kaam krta hai ) hindi me mtlb iska AUR

: ye true ans tbhi deta hai jb dono values sch hoti hai ( this is imp*****)

: agr dono vale me ek hi value false hogyi toh ans false ho jayega

3rd) or ( do value pe work krega ) mtlb iska YA

: dono me ek bhi values sahi hue toh toh ye ans true dega(this is imp*******)

: agr dono value false hogyi toh ye hume false dega .

4. \n is a escape squence jiska mtlb hota hai next line agr kisi string ko hume do
line me convert krna hai toh bich me lga do .
\t se tab ka space aa jayega mtlb sentence ke bich space aa jayega .

5. indexing meaning position dena


6. jb bhi hum string ke tukre kr dete hai python me use hum slicing bolte hai .
7. " " agr hum ye likh kr chod denge nhi string ki length count krenge toh ye bhi
count hoga .
8. syntax means rules of programming.
9. elif means else if (agar ) kuch or condition in simple term
10.conditional statement ke sath humesha : ( colon ) ke baad four space tab chodne
pdhte hai print se phele called INDENTATION.
11. elif ki staement tbhi print hogi jb if ki statement false hogi . nhi toh if ki
hi statement humesha print hogi .
12. else statement tb run krega jb if and elif false ho jaye nhi toh nhi krega.
13.Nesting means if statement ke ander ek aur if statement. ( jo four tab gap chora
hai udr aa jaye ) .
eg . if( condi 1 ) :
if(condi 2 ) :
print( " " )
14. list banane ke liye hum square bracket ka use krte hai unko coma se separate
krte hai .
15. list me index ki trh hi use hota hai .
16. lists are mutable ( things can change )
strings are immutable ( things cannot change )
17. list ke functions none value return krte hai after changing things in code
18. tuples are immutable
19. tuples me hum ( ) ye bracket use krte hai
20.in tuples for single character we have to put , ( coma ) in the end fir the
tuple type .
21 PALINDROME means things jo aage or piche se same hoti .
22. palindrome banane ke liye :
* phele list ko copy krenge
* fir copied list ko reverse kr denge
* yahi reverse list hamari first list ki PALINDROME bn jayegi
23. dic.update() ke bich me {} curly bracket aynge jb hume kuch new key : value
update krni hogi .
24.dictionary me indexing no of keys se hoti hai jitni keys utne hi index .
25. empty dictionary = {} ( syntax of a empty dictionary )
26. empty set = set() ( syntax of a empty set )
27. hasable = immutable value ( strings , tuples )
28 unhasable value = mutable values ( dict , list , sets )
29. jab bhi hume same two number store krne ho set ke ander toh for eg 9 & 9.0 toh
"9.0"(aise string me save krdo toh ye number store ho jayega ) or "9" and 9.0 ye
bhi kr skte hai .

isi ka dusra tarika hai ki hum use kre build in data type mtlb data ko unke samne
unka data type likhkr tuple ki form me store kra dena

eg. values = {
("float" , 9.0 )
("int" , 9 )

}
print(values)

iska result { ('float' , 9.0 ) ,('int' , 9 ) }

30. while meaning is ( jab tak ) .

31. loops me variable ko iterators bolte hai and loop 1 bari complete hona usko hum
iteration bolte hai .
31. traverse means hum ek ek element ke uper jare hai or travel kr rhe hai or usko
print kr rhe hai while loop lga kr .
32. continue in while loop act as skip . ye ek chiz ko skip kr dega and next pe
pahuch jayega ( or simple ignore kr dega ) .
33. range me ending number include nhi hota . eg print(range(5)) then 0 ,1 ,
2 ,3 ,4 print ho jynge but 5 nhi aaya.
34. range me step mtlb increment kitne se increase kr rha hai .
35 range me start ki value included hoti hai but stop ki value included nhi hoti .
36. pass mtlb loop ke ander koi kaam nhi krana toh vo chiz use skip krdega and next
kaam pr work krega .
37. redundant means to repeat .
38. jo function input leta hai use hum paarameter bolte hai or kuvh output return
krta hai .
39. jab hume function ko call krna hota hai toh hum function ka naam likhte hai and
usme kuch argument dalte hai and these argument going to store in parameters
40. loop and recursion same hi hote hai jo kaam hum recursion se kr skte hai vahi
kaam hum loop se bhi kr skte hai .
41. jab bhi hum multiple statement ko same line me print krna chahte ho tb end = "
' ye daldo .
42. built in function vo hote hai jo phele se define hote hai python me .
43. jo function user lihte hai use hum user defined function kehte hai .
44. defauts parameter vo hote hai jb hum koi function call krre hote or usme
argument nhi hoti hai toh hum main function ke parameter me kuch value khudse de
skte hai eg def function(a = 2,b=7)
45.

You might also like