-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull python code.py
More file actions
2615 lines (1950 loc) · 61.6 KB
/
full python code.py
File metadata and controls
2615 lines (1950 loc) · 61.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""
print("this is \\\\ double backslash")
print("this is /\\/\\/\\/\\/\\ mountain")
print("he is \t awesome (use escape of )")
print("\\\" \\n\\t \\'")
a=4
b=3
c=a*b
print("the total is " + str(c))
--------------------------------------------------------------------------------------------------
a=56
b=55
print(a+b) #addition
print(a-b) # subtration
print(a*b) # multiplication
print(a/b) #float division4
print(a//b) #int division5
print(a**b) #to find the power
print(a**.5) # to find the under root use .5
print(round(a**.5 ,4)) # to find the root upto the given digits
print(a%b) # to find the remainder
print((4*3+2)*4*(5+3*6)/4*3**2) # to solve this
-------------------------------------------------------------------------------------------
CH ---2
# VARIABLES
name = "rithilk"
print(name)
age = 56
print(age)
name = "ankush" # python is a dynamic programing language becouse it can change its value
print(name) # name variable can be use in many time .....
# CONDITIONS OF VARIABLES :-
# variable can not be started from no for ex (1num)
#no special symbols are used in this language
print("hii")
--------------------------------------------------------------------------------------------
#STRING AND USER INPUT
name = input("enter your name ")
print("your name is " + name )
age= input("enter your age ")
print("your age is :-" +age )
# USER INPUT
a = int(input("enter your no "))
b= int(input("enter your 2 no:- "))
c= a+b
print("total is " + str(c))
# MULTIPLES VARIABLES IN SAME LINE:-
name , age = input("enter your name "), int(input("your age :- "))
print("hello " + name +" "+ "your age is :-" + str(age))
# MULTIPLE VARIABLES IN SINGLE INPUT
name ,age, standard , section, rollno = input("enter your details:-").split()
print("your name is :-"+name +"\n""your age is :-"+age +"\n""your standard is :-"+standard+"\n""your section is :-"+section+"\n""your roll no is :-"+rollno)
--------------------------------------------------------------------------------------------------------
# STRING FORMATING:-
name ="rithik"
rollno = 33
print("hello {} your rollno is {}".format(name , rollno)) # in this we do not have to mention the string type
# EXERCISE
no1 , no2 ,no3 =input("enter three no:-").split()
d= (int(no1)+int(no2)+int(no3))/3
print(d)
# another method
no1 ,no2,no3= input("enter three no:-").split()
print("your average is {}".format((int(no1)+int(no2)+int(no3))/3))
----------------------------------------------------------------------------------------------------------------------------------------------------
# STRING INDEXING
language = "python"
#position (index no )
# p = 0
# y= 1
# t= 2
# h= 3
# o= 4
# n= 5
print(language[5])
#STRING SLICING
language ="python"
# print(language[start agrument : stop argument-1])
print(language[0:6])
# STEP ARGUMENT
print("language"[0:6:2])# to skip the next element we have to add the step argument
# to reverse the string we use step argument:-
print("language"[::-1])
-------------------------------------------------------------------------------------------------
# to ask the user and print back user name in reverse order.
name = input("enter your name:-")
print("your name is {}".format(name[::-1]))
#ANOTHER METHOD
name = input("enter your name:-")
print(name[::-1])
-------------------------------------------------------------------------------------------------
# STRING METHOD 1
#1 len() funtion
print(len("rithik soun"))
#or
rs= "rithik soun"
print(len(rs))
#or
rs = "rithik soun"
rr = len(rs)
print(rr)
# 2 lower() method (to change the all alphabets in lower order)
print("rIThIK SOUn".lower())
# 3 upper() method (to change the all alphabets in upper order)
print("rIThIK SOUn".upper())
# 4 title() method
print("rIThIK SOUn".title())
# 5 count() method (to check the no of times the alphabets occur)
print("rIThIK SOUn".count("r"))
-----------------------------------------------------------------------------------
# print the name and character and count the no of alphabets :-
name , ch = input("enter your name and character :-").split(",")
print(len(name), name.count(ch))
# or
name , ch = input("enter your name and character :-").split(",")
print("your length is:- {}".format((len(name))),"your character:- {}".format(name.count(ch)))
#or if the cases are sensative
name , ch = input("enter your name and character :-").split(",")
print("your length is:- {}".format((len(name))),"your character:- {}".format(name.lower().count(ch.lower())) )
#STRIP METHOD (TO REMOVE THE SPACES )
name = " rithik soun "
dots = "............................."
print(name.strip() + dots) # it remove all the extra spaces
#lstrip() it remove all the left spaces
#rstrip() it remove all the right spaces
#note it does not remove the spaces b\w the variables
print(name.lstrip() + dots)
print(name.rstrip() + dots)
# replace("the variable that is remove ","the variable that can be replace")
print(name.replace("i","o") +dots.replace(".","'"))
# if you want to remove the space b\w the second ch then we have to add replace
name , ch = input("enter your name and character :-").split(",")
print("your length is:- {}".format((len(name))),"your character:- {}".format(name.lower().count(ch.lower().replace(" ",""))) )
#REPLACE AND FIND METHOD
#replace(" " ," ",how many words do you change )
name ="helo i am a good boy and i can do any thing without any body"
print(name.replace("any ","no",1))
#find() methiod (to check the position of any character)
name ="helo i am a good boy and i can do any thing without any body"
print(name.find("any",2)) # if you want to check th another position of the variable than we can set the position of the previous one
#if you want to find the position of second any without findind the first position than
name ="helo i am a good boy and i can do any thing without any body"
any_1 = name.find("any")
any_2 = name.find("any" ,any_1+1)
print(any_2)
# CENTER METHOD
name = "RITHIK SOUN"
print(name.center(21 ,"*"))
# QUESTION:-
name =input("enter your name :-")
a= len(name)
l=int(a+8)
print(name.center(l,"*"))
#or
name =input("enter your name :-")
print("{}".format(name.center(len(name)+8,"*")))
print("welcome to the calculator\nOPERATIONS ARE:0 \n1) SUM\n2) SUB\n3) MUL\n4) DIV ")
Z = input("enter your operation:-")
a , b =input("enter the value of A and B:-").split(",")
print("sum{}".format(int(a)+int(b)))
print("sub{}".format(int(a)-int(b)))
print("mul{}".format(int(a)*int(b)))
print("div{}".format(int(a)/int(b)))
---------------------------------------------------------------------------------------------------------------------------------------------------
CH ---3
# IF STATEMENT ANS ELSE STATEMENT:-----
age = int(input("enter your age :-"))
if age >= 14: # use this (:) to run the program and in this language we does not have to use the currly bracces
print("you are adult")
else:
print("grow up dude")
# PASS STATEMENT(IF YOU WANT TO PASS ANY COMMAND SO YOU CAN USE THE PASS STATEMENT)
AGE = int(44)
if age >= 14:
pass
# questiuon
rnum = int(88)
num = int(input("enter your no :-"))
if num == rnum:
print("YOU WIN !!!!!")
else:
if num > rnum:
print("too high")
else:
ma print("too low")
# AND , OR OPERATER
gender = input("enter your gender:-")
age = int(input("enter your age :-"))
if gender== "male" and age <= 18: # using (and) condition all condition are compulsory and if we use (or) then only one condition should be true
print("you are elligible to vote")
else:
print("you are a child bro")
#QUESTION
name = input("enter your name:-")
age = int(input("enter your age :-"))
if name[0] =='a' or name[0]=='A' and age>= 10:
print("you can watch coco movie")
else:
print("sorry, you can't watch the movie")
# IF_ELIF_ ELSE STATEMENT:-0
# use this command to set the various else condition using (elif)
age = int(input("enter your age :-"))
if 0<=age<=3:
print("ticket prize is free()")
elif 3<age<=20:
print("ticket prize is 200()")
elif 20<age<=60:
print("ticket prize is 250()")
else:
print("ticket prize is free()")
# in(keyword) it is used to check the elphbets present in the given varaibles or not :-
name = input("enter your name :-")
if 'r[0]' in name :
print("yes present")
else:
print("not present")
# MINI CALCULATER:-----------------------------------------------------------------------------
print("welcome to the calculator\nOPERATIONS ARE:0 \n1) SUM\n2) SUB\n3) MUL\n4) DIV ")
z = int(input("enter your operation:-"))
a ,b =input("enter the value of A and B:-").split(",")
if z==1:
print("sum:-{}".format(int(a)+int(b)))
elif z==2:
print("sub:-{}".format(int(a)-int(b)))
elif z== 3:
print("mul:-{}".format(int(a)*int(b)))
else:
print("div:-{}".format(int(a)/int(b)))
# loops
#( while loop:-) ---------------
i=1
while i<=100:
print("hello")
i= i+1
# 1question
#(ask the user to sum the all given no:0)
no1 , no2 = input("enter your starting and ending no:-").split(",")
total = 0
i= int(no1)
while i<= int(no2):
total = total +i
i=i+1
print(total)
# 2QUESTION
#(ASK THE USER TO TYPE THE NO AND ADD THAT NO EX:- 1234:____1+2+3+4)
no = input("enter your no:-")
l =len(no)
total = 0
i = 0
while i<l:
total = total+ int(no[i])
i=i+1
print(total)
#12345
#01234
# 3 QUESTION
# (ASK THE USER TO TYPE THE NAME AND PRINT THAT NAMER HOW MANY TIMES THE ALPHABETS COMES :-)
name = input("enter your name:-")
#var = ""
i = 0
while i< len(name):
#if name[i] not in var:
# var=var+ name[i]
print(name[i] ,name.count(name[i])
i=i+1
# INFINITE LOOP
while True:
print("hello world")
# for loop-----------------------------------------------------
for i in range(1,101):
print("hello",i)
# 1 question (sum from 1 to 100) ( IN THIS I ADD THE N AND L VARIABLE SO THAT USER CAN ADD THE STARTING AND ENDING VALUE )
n,l = input("enter the starting and ending value :-").split(",")
total = 0
for i in range(int(n),int(l)):
total = total + int(i)
print(total)
# 2 QUESTION
#(ASK THE USER TO TYPE THE NO AND ADD THAT NO EX:- 1234:____1+2+3+4)
no = input("enter the no:-")
#1234
total = 0
for i in range(0,len(no)):
total= total + int(no[i])
print(total)
# 3 QUESTION
#(ASK THE USER TO TYPE THE NAME AND PRINT THAT NAMER HOW MANY TIMES THE ALPHABETS COMES :-)
name = input("enter your name ")
for i in range(0,len(name)):
print(name[i],name.count(name[i]))
# BREAK AND CONTINUE KEYWORDS:-
#BREAK:---
for i in range(0,10):
if i == 5:
break # it break the line and exit the program
else:
print("hello")
# CONTINUE:--------
for i in range(0,10):
if i == 5:
continue # it continue the program and does not print the given value
else:
print(i)
# QUESTION :-
w_no = int(88)
game_over = False
guess = 1
u_no = int(input("guess a no b/w 0 to 100:--"))
while not game_over:
if u_no == w_no:
print("you win","and you guessed this no in",guess)
game_over = True
elif u_no > w_no:
print("too high")
guess += 1
u_no = int(input("guess again"))
else:
print("too low")
guess += 1
u_no = int(input("guess again"))
# loop
# to add the random no we use :-
import random
winning_no = random.randint(1,100)
# or
import random
w_no = random.randint(1,100)
game_over = False
guess = 1
u_no = int(input("guess a no b/w 0 to 100:--"))
while not game_over:
if u_no == w_no:
print("you win","and you guessed this no in",guess)
game_over = True
elif u_no > w_no:
print("too high")
guess += 1
u_no = int(input("guess again"))
else:
print("too low")
guess += 1
u_no = int(input("guess again"))
# STEP ARGUMENT IN FOR LOOP:---------
for i in range(10,1,-1):
print(i)
# STRING FORMATING IN FOR LOOP::----
name =input("name is:-")
for i in range(0,len(name)):
print(name[i])
#OR WE CAN USE THE STRING METHOD TO DECREASE THE LEANGTH:----
name ="rithik"
for i in name:
print(i)
no = input("enter your no:-")
#1234
total = 0
for i in no: # in this we does not want to add tye range so we just simply type the variable so tht it help us
total += int(i)
print(total)
CH 4
_____________FUNCTION_________________
# FUNTIONS:
def funtion name (no1,no2):(_this is also known as a parameter__ and when the user add that is known as argument)# in this we does not have to add the parameter
return no1+no2 # print(no1+no2) (IN THIS WE CAN ALSO USE THE PRINT FUNTION SO THAT THE FUNTION WILL AUTOMATICALLY PRINT THE FUNTION WITHIOUT THE RETURN TYPE )
# make a funtion
def call(no,no2):
return(no+no2)
total= call(22,22)
print(total)
# for thr user input :----
def call (no1,no2):
return(no1+no2)
a= int(input("enter your first no-"))
b= int(input("enter your second no-"))
print(call(a,b))
# PRACISE OF FUNCTION:_____
# to askt he user to type the name and print that last no:-------
name = input("enter your name pls:-")
def nam(a):
return name[-1]
print(nam(name))
# to check the no odd or even:-
def new(a):
return(a%2)
no = int(input("enter your no:-"))
if new(no)==0:
print("no is even")
else:
print("no is odd")
# another method:-----
# in this we add the if statemnet in the funtion
def no(a):
if a%2 == 0:
return "even"
return"odd"
new_no = int(input("enter your no"))
print(no(new_no))
# another method
def no(a):
return a%2 ==0
n= int(input("enter your no"))
print(no(n))
#EXERCISE
# TO CHECK THE GREATEST OF TWO NO
def new(a,b):
if a>b:
return a
else:
return b
no1 ,no2 =input("entre two no:- ").split(",")
print(new(no1,no2),"is greater")
#EXERCISE
#GREATEST OF THREE NO:-------------
def greater(a,b,c):
if a>b and a>c:
return a
elif b>c:
return b
else:
return c
no1,no2,no3 = input("enter the three no:-").split(",")
print(greater(no1,no2,no3),"is greater")
#FUNTION INSIDE THE FUNTION":-------------
def greater(a,b):
if a>b:
return a
else:
return b # first we have to make trhe greteast of two no and aftre that call thet funtion in greatest
def greatest(a,b,c):
bigger = greater(a,b)
return greater(bigger,c) # in this greater and c value again goes to greater funtion and calculate that value
no1,no2,no3 = input("enter the three no:-").split(",")
print(greatest(no1,no2,no3),"is greater") # we have to call the greatest funtion
#palandrom no:-------------
name = input("enter your name")
def rev(a):
reverse = a[::-1]
if a == reverse:
return True
else:
return False
print(rev(name))
# fibonacci series
# 0 , 1 ,1 ,2 ,3 ,5 ,8 ,13 ,
def feb(n):
a = 0
b= 1
if n == 1:
print(a)
elif n == 2:
print(a ,b)
else:
print(a ,b ,end=" ")
for i in range(n-2):
c= a+b
a=b
b=c
print(c ,end=" ")
feb(25)
# SCOPE:----------------
# IN THIS IF WE WANT TO CALL THE VARIABLE THAN WE HAVE TO USE THE FUNTION ONLY
#FOR EX
a=7
def var(): # if we want to print the a variable than we have to call the var()
global a # if we want to use the outside variable than we have to add global
a=5
return a
print(a)
print(var())
print(a)
________________________CH -5______________________________________
INTRO TO LIST
# list of no
# to store the data we use the data
no = 1,2,3,4,5
print(no)
# we can also store the all caracters also :-----
min = 1,2,"rithik", 2.3,None
print(min[::+2]) # we also add the slicing also to print the specific one using indexing
# to change the variable in the list
min = [1,2,"rithik", 2.3,None]
min[2] ='two'
print(min)
# to add data in the list we use append method :----
min = [1,2,"rithik", 2.3,None]
min.append('ankush')
print(min)
# ANOTHER METHOD TO STORE DATA
# insert method
min = [1,2,"rithik", 2.3,None]
min.insert(1,"ankush")
print(min)
#to add two list :-----
min1 = [1,2,"rithik", 2.3,None]
min2 = [3,4,"ankush", 2,None]
total = min1+min2
print(total)
# to add the one list in another one
# use extend method
min1 = [1,2,"rithik", 2.3,None]
min2 = [3,4,"ankush", 2,None]
min1.extend(min2)
print(min1)
print(min2)
# to delete the data in the list :------
# use pop method:0
min1 = [1,2,"rithik", 2.3,None]
min1.pop(1)# if you does not pass the argument than it delete the last item in the list
print(min1)
# del operater
del min1[2]
print(min1)
# remove method:--
min1 = [1,2,"rithik", 2.3,None]
min1.remove(2.3)
print(min1)
# to arrange the list in sort order:
# use sort method:-
min1 = [1,2,1,8,3,5,6,3,2.3]
min1.sort()# use sort() method
print(min1)
min1 = ['a','g','b','x','f','v','n','u','u']
min1.sort()# use sort() method
print(min1)
# sorted funtion
#it print the sorted list but does not sort the array:-----
min1 = [1,2,1,8,3,5,6,3,2.3]
print(sorted (min1))
print(min1)
# clear to clear the list
# copy to copy the no
min1 = [1,2,1,8,3,5,6,3,2.3]
min1.clear()
print(min1)
# copy
min1 = [1,2,1,8,3,5,6,3,2.3]
min2 = min1.copy()
print(min2)
# join method
#convert list to string:-
user= ['rithik','33']
print(','.join(user))
#using list in for loop
fruits = ['apple', 'mango','grapes','bannana']
for i in fruits:
print(i , end = ", ")
# list inside list:---
# EXERCISE
# TO ADD THE LIST AND MAKE THE SQUARE OF EACH ELEMENT IN THE LIST:-
num = list(range(1,12))
def sqr(n):
square =[]
for i in n:
square.append(i**2)
return square
print(sqr(num))
#EXERCISE
# to reverse the given list without using slicing or reverse method:--
ls = [1,2,3,4,5,6,7]
def rev(n):
emp =[]
for i in range(len(n)):
epe = ls.pop()
emp.append(epe)
return emp
# emp.append(print(ls.pop))
print(rev(ls))
#EXERCISE:-----
ls = ['abc','huv','jkl']
def ver(a):
emp =[]
for i in a:
emp.append(i[::-1])
return emp
print(ver(ls))
# EXRECISE
# [1,2,3,4,5,6] ::: INPUT
#[[1,3,5],[2,4,6]]
ls = [1,2,3,4,5,6,7,8,9]
def lp(n):
emp =[]
evenl=[]
oddl=[]
for i in n:
if i%2==0:
evenl.append(i)
else:
oddl.append(i)
emp.append(evenl)
emp.append(oddl)
return emp
print(lp(ls))
# eXERCISE:-
#[1,2,3,4,5],[7,2,5,6,1] INPUT
#[1,2,5] OUTPUT
l1 = [1,2,3,7,6,9,18,4,5]
l2 = [18,7,2,5,6,1,]
def com(n):
emp =[]
for i in l1:
for j in l2:
if j==i:
emp.append(i)
else:
j+=1
return emp
print(com(l1))
# min and max funtion:---
no = [1,3,2,44,22,99]
print(max(no))
print(min(no))
no = [1,3,2,44,22,99]
# now suntract bigger from smaller no:-
def su(l):
a = max(l)
b = min(l)
return a-b
print(su(no))
# exercise:-
ls = [1,2,[3,4,2,1],[1,6,5,7,5],[7,8,6,5]]
def le(l):
count = 0
for i in l:
if type(i)==list:
count+=1
return count
print(le(ls))
CH ---6
TUPLES
----------------------
# it is immutable , it is represent bo simple() parantheses .
namere= (1,2,3,4,5,6,7,8,9) # this is tuple
print(namere)
CH - 7
DICTIONARIES:---
user = {'name' : 'rithik' , 'age': '33'}
print(user)
#or another method:-
user =dict(name = 'rithik', age = 33)
# it can be represent by the dict
print(user)
# to add the data in the dictionaries:-
user =dict()
user['name'] = 'rithik'
print(user)
# in keywords and looping:-
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
if 'names' in user:
print("present")
else:
print("not present")
# to check the inner values use (.values())
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
if 'rithik' in user.values():
print("present")
else:
print("not present")
# looping in dictonaries:-__________
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
for i in user.values():
print(i)
# keys method(.keys())
# to print the keys
# item method:------------
# to print all the items in the dict:--------
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
user_j= user.items()
print(user_j)
#ADD DATA IN THE LIST
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
user['class']='12th'
print(user)
# TO DEL THE DATA
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths',
cls1= '12th')
userpoped=user.pop('cls1')
print(user)
print("the poped item is", userpoped)
# TO RaNDOM DEL ITEM
user = dict(name = 'rithik',
rollno = 1816864,
subject = 'maths')
print(user)
popeditem = user.popitem()
print(user)
print('poped item is', popeditem)