-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathComplete_Python.py
1868 lines (1254 loc) · 45.9 KB
/
Complete_Python.py
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
# What Is Python?
"""
+ Python Is a Popular Programming Language. It was created by Guido van Rossum, And Released In 1991.
+ Python Is a Interpreted Language.
+ It Is Used For:
+ 1): Web Development (Server-Side),
+ 2): Software Development,
+ 3): Mathematics,
+ 4): System Scripting.
# What can Python do?
+ Python can be used on a server to create web applications.
+ Python can be used alongside software to create workflows.
+ Python can connect to database systems. It can also read and modify files.
+ Python can be used to handle big data and perform complex mathematics.
+ Python can be used for rapid prototyping, or for production-ready software development.
# Why Python?
+ Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).
+ Python has a simple syntax similar to the English language.
+ Python has syntax that allows developers to write programs with fewer lines than some other programming languages.
+ Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.
+ Python can be treated in a procedural way, an object-oriented way or a functional way.
# Python Syntax compared to other programming languages:
+ Python was designed for readability, and has some similarities to the English language with influence from mathematics.
+ Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.
+ Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
# Installing Python Setup:
+ Download Anaconda Navigator Website_Name Go(https://www.anaconda.com/products/individual#Downloads). Then Selected Option (Window, MacOS, Linux).
+ Download Completed Then Opon Anaconda Then Accept All Argrements Then Open Anaconda Then Launch ((Jupyter)NoteBook) Version(6.3.0).
+ Then Open Jupyter in Google then Press New Button then Select Option (Python 3)
+ Then Your Browser In Always Open This Https: (http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3)
+ Then Write Your Coading Inside (In[]: Input)
# For Example:
Press Run Button
⬇️
* print("Hello World") ===> Output Is: (Hello World)
# No Need:
+ No need of var int or double in python.
+ variable declearation.
+ variable initiallization.
# Variable:
+ Variables are containers for storing data values.
+ A variable is created the moment you first assign a value to it.
+ Variables do not need to be declared with any particular type, and can even change type after they have been set.
# For Example:
(a) Is a Variable Name
Equal (Operator)
(5) Is Value Of (a) Variable
⬇️⬇️⬇️
* a = 5 ===> Varible Inside Value.
* print(a) ===> Print (a) Variable Value.
# Work On:
* VariableName = Value
# String Expression:
* populor_string = "This Is String Value"
* print(populor_string)
# Math Expression:
* populor_number = 5
* print(populor_number)
# Math Expression: Familiar Operators:
# Addition:
* addition = 5 + 5
* print(addition) # 10
# Subtraction:
* subtraction = 15 - 5
* print(subtraction) # 10
# MultipliCation:
* multipliCation = 5 * 2
* print(multipliCation) # 10
# Division:
* division = 15 / 5
* print(division) # 3.0
# Module:
* module = 20 % 6
* print(module) # 2
# Decimal Value:
* num = .075 ===> This Is a Decimal Value.
* total = num + 200 ===> Concatenating.
* print(total) ===> 200.075
# Variable Names Legal & Illegal:
+ You've already learned three rules about naming a variable:
1. You can't enclose it in quotation marks.
2. You can't have any spaces in it.
3. It can't be a number or begin with a number.
+ In addition, a variable can't be any of Python's reserved words, also known as
keywords—the special words that act as programming instructions, like print.
Here’s a list of them.
# and False not
# as finally or
# assert for pass
# break from print
# class global raise
# continue if return
# def import True
# del in try
# elif is while
# else lambda with
# except none yield
# nonlocal
# Code:
* a = 5
* a = a+1
* print(a) ===> Output Is: (6)
# Same Work:
* a = 10
* a += 2
* print(a) ===> Output Is: (12)
# Math Expresstion: Eliminating Ambiguity(DMAS Rule):
* dmas = 1 + 3 * 4
* print(dmas) ===> Output Is: (13)
* dmas = (1 + 3) * 4
* print(dmas) ===> Output Is: (16)
* dmas = (1 + 3) * 4 / 2
* print(dmas) ===> Output Is: (8.0)
* dmas = (1 + 3) * 4 // 2
* print(dmas) ===> Output Is: (8)
# Assignment No_(1):
+ Step_(1):
* print("Twinkle, twinkle, little star, ")
* print(" How I wonder what you are!")
* print(" Up above the world so high, ")
* print(" Like a diamond in the sky. ")
* print("Twinkle, twinkle, little star,")
* print(" How I wonder what you are")
+ Second Optioin(One print Of Code)
* print("Twinkle, twinkle, little star,\n How I wonder what you are!\n Up above the world so high, \n Like a diamond in the sky. \nTwinkle, twinkle, little star,\n How I wonder what you are")
+ Step_(2):
* version = "3.8.8 (default, Apr 13 2021, 15:08:07) [MSC v.1916 32 bit (Intel)]"
* print(version)
+ Output Is:
+ 3.8.8 (default, Apr 13 2021, 15:08:07) [MSC v.1916 32 bit (Intel)]
+ Second Option("Import Sys")
* import sys
* print(sys.version)
+ Output Is:
+ 3.8.8 (default, Apr 13 2021, 15:08:07) [MSC v.1916 32 bit (Intel)]
+ Step_(3):
* text = "Current Date And Time: "
* date = "2021-05-16 04:12:38"
* print(text)
* print(date)
+ Output Is:
+ Current Date And Time:
+ 2021-05-16 04:12:38
+ Second Option("Import DateTime")
* import datetime
* now = datetime.datetime.now()
* print("Current Date And Time: ")
* print(now.strftime("%Y-%m-%d %H:%M:%S"))
+ Output Is:
+ Current Date And Time:
+ 2021-05-16 04:12:38
+ Step_(4):
*
+ Step_(5):
* firstname = "Mark"
* lastname = "Myers"
* print("Fullname Is: " + lastname +" "+ firstname)
+ Output Is:
+ Fullname Is: Myers Mark
+ Second Option("Input Throw")
* firstname = input("Enter your Firstname: ")
* lastname = input("Enter your Lastname: ")
* print("Fullname Is: " + lastname +" "+ firstname)
+ Output Is:
+ Fullname Is: Myers Mark
+ Step_(6):
* num1 = 18
* num2 = 2
* print(num1+num2)
+ Output Is:
+ 20
+ Second Option("Input Throw")
* num1 = input("Enter your num1: ")
* num2 = input("Enter your num2: ")
* print(int(num1)+int(num2))
+ Output Is:
+ 20
# Assignment No_(1) Is Completed
# Concatenation
* str = "Jibran"
* str1 = "Abdul Jabbar"
* punc = "!"
* print(str + ' ' + str1 + " " + punc)
# Arithmetic Operation
* () / * + - ** // %
* >>> 20 / 2
* 10.0 (a float?)
* >>> 3/0
+ ZeroDivisonError: division by Zero
* >>> 5 + 3.0
* 8.0
* >>> 2 ** 3 >>> Powered Discuss
* 8
+ Powered Discuss (**)
* num = 5
* num1 = 2
* print(num ** num1)
+ Output Is:
+ 25
+ Second Option(**)
* num = 3
* num1 = 2
* print(num ** num1)
+ Output Is:
+ 9
+ Third Option(**)
* num = 4
* num1 = 2
* print(num ** num1)
+ Output Is:
+ 16
# Arithmetic Operation_(Cont)
* >>> 15.0 // 2.0 (floor division)
* 7
* >>> 15.0 % 2.0 (remainder)
* 1
# String (Theory)
+ A String is created by entering a text between two double quotations or two single quotes.
* >>> 'We are Programmers'
'We are Programmers'
* Three Quotes String
'''Whatever I write here
will be displayed
as it is'''
+ String Is a Group Of Character.
# String (Cont)
>>> print('one,' + ' two,' + ' three')
+ Output Is:
+ one, two, three
>>> '5' + '3'
+ Output Is:
+ 53 (not 8)
>>> '1' + 5
+ Output Is:
+ TypeError: unsupported operand types
>>> print(" Hello World " * 5)
+ Output Is:
+ Hello World Hello World Hello World Hello World Hello World
>>> print(5 * " Hello World ")
+ Output Is:
+ Hello World Hello World Hello World Hello World Hello World
>>> print(" Hello World " * 5.0)
+ Output Is:
+ TypeError
>>> print('Hello' * 'World')
+ Output Is:
+ TypeError
# Simple Input/Output
>>> print('Python is cool')
+ Output Is:
+ Python is cool
# Line Break In Python Print
>>> print('You are \n Welcome')
+ Output Is:
+ You are
+ Welcome
# Variable Input
+ Input Always take the Values as String.
* x = input("Enter your age: ")
+ Enter your age: 8
>>> print(x)
+ Output Is:
* 8
# Format Function In Python
* marks = "79"
* percentage = "80.0000000%"
* print("Marks: {} - Percentage: {}".format(marks , percentage))
+ Output Is:
+ Marks: 79 - Percentage: 80.0000000%
# Float
* x = input("Enter your value: ")
* y = 18
* z = float(x) + y
* print(z)
+ Output Is:
+ Enter your value: 5
+ 23.0
+ Second Option(Use Float ==> input)
* x = float(input("Enter your value: "))
* y = 18
* z = x + y
* print(z)
+ Output Is:
+ Enter your value: 5
+ 23.0
# Integer(int ===> Keyword)
+ Use Int() Function to Convert String into Integer.
* x = input("Enter your value: ")
* y = 18
* z = int(x) + y
* print(z)
+ Output Is:
+ Enter your value: 5
+ 23
+ Second Option(Use Integer ==> input)
* x = int(input("Enter your value: "))
* y = 18
* z = x + y
* print(z)
+ Output Is:
+ Enter your value: 5
+ 23
# Single Line Comment (#)
# This Is Single Line Comment TexT
# Multi Line Comment (""" """)
* This Is Multi Line Comment TexT ===> """ """
# IF/Else Statement In Python
* age = int(input("Enter your age: "))
* if age >= 15 :
* print("You are Allowed To This Ride")
* else :
* print("You are Not Allowed to This Ride")
+ Output Is:
+ Enter your age: 17
+ You are Allowed To This Ride
+ Second Condition
* if 2+2 == 4 :
* print("2 + 2 Is Equal To 4")
+ Output Is:
+ 2 + 2 Is Equal To 4
# Comparison Operators
* a = 5
* b = 15
* c = 5
* d = 5
* if a+d == b-c :
* print("Your Answer Is Correct..!")
* else :
* print("Your Answer Is WronG..!")
+ Output Is:
+ Your Answer Is Correct..!
# Not Equal To Operator
* a = 5
* b = 15 ==> 22
* c = 5
* d = 5 ==> 20
* if a+d != b-c :
* print("Your Answer Is Correct..!")
* else :
* print("Your Answer Is WronG..!")
+ Output Is:
+ Your Answer Is WronG..!
+ Here are 4 more comparison operators, usually used to compare numbers.
+ > Is Greater than
+ < Is Lass than
+ >= Is Greater than or Equal to
+ <= Is Less than or Equal to
+ In the Examples below, all the Conditions are True.
* if 1 > 0 :
* if 0 < 1 :
* if 1 >= 0 :
* if 1 >= 1 :
* if 0 <= 1 :
* if 1 <= 1 :
# Else/ElIF Statement
* course_name = input("Enter Your CourSe Name: ")
* if course_name == "Python" :
* print("Python Is Cool")
* elif course_name == "JavaScript" :
* print("JavaScript Is Cool")
* elif course_name == "HTML & CSS" :
* print("HTML & CSS")
* else :
* print("All Courses Is COOL..!")
+ Output Is:
+ Enter Your CourSe Name: Python
+ Python Is Cool
# (IF/Else/ElIF) Statement Percentage Example Uses (and/or)
* percent = int(input("Enter Your Percent: "))
* if percent >= 80 and percent <= 100 :
* print("A+")
* elif percent >= 70 and percent <= 80 :
* print("A")
* elif percent >= 60 and percent <= 70 :
* print("B")
* elif percent >= 50 and percent <= 60 :
* print("C")
* elif percent >= 40 and percent <= 50 :
* print("D")
* elif percent >= 33 and percent <= 40 :
* print("E")
* elif percent >= 0 and percent <= 33 :
* print("Fail")
* else :
* print("You have given Inapproperiate Percentage_(%) ")
# (IF/Else/ElIF) Statement Simple CalCulator Example Uses (and/or)
* num1 = int(input("Enter Your Num1: "))
* operator = input("Enter Your Operator: ")
* num2 = int(input("Enter Your Num2: "))
* if operator == "+" :
* print("Answer Is: ", num1 + num2)
* elif operator == "-" :
* print("Answer Is: ", num1 - num2)
* elif operator == "*" :
* print("Answer Is: ", num1 * num2)
* elif operator == "/" :
* print("Answer Is: ", num1 / num2)
* elif operator == "%" :
* print("Answer Is: ", num1 % num2)
* else :
* print("Make a Mistake!")
# (IF/Else/ElIF) Statement Prize Bond Example Uses (and/or)
* ticket_luck = int(input("Enter your Ticket No: "))
* if ticket_luck == 18341 :
* print("Congratulations (1st Prize) Price: ($50000)")
* elif ticket_luck == 18342 :
* print("Congratulations (2nd Prize) Price: ($30000)")
* elif ticket_luck == 18343 :
* print("Congratulations (3rd Prize) Price: ($10000)")
* else :
* print("Bad Luck Next Time Try Again")
# Nested (IF/Else/ElIF) Statement:
* a = 5;
* b = 6;
* c = 7;
* d = 7;
* e = 9;
* g = 10;
* f = 11;
* x = 12;
* y = 12;
* h = 0;
* if (x == y or a == b) and c == d : ==> ( (x == y ==> 12 == 12) or (a == b ==> 5 == 6) ) and (c == d ==> 7 == 7)
* g = h
* print(g)
* else :
* e = f
* print(e)
# Second Condition Same Condition (Nested (IF/Else/ElIf))
* a = 5;
* b = 6;
* c = 7;
* d = 7;
* e = 9;
* g = 10;
* f = 11;
* x = 12;
* y = 12;
* h = 0;
* if c == d :
* if a == b :
* g = h
* print(g)
* elif x == y :
* g = h
* print(g)
* else :
* e = f
* else:
* e = f
# List (Array)
+ We can store one or more elements in the list.
+ List & Array Is a Group of Element.
+ Each element in the list has a unique id through which we see the value of that ID.
+ Lists are created using square brackets:
* arr = ["Array",1,False,"List",1.33,True]
* print(arr)
+ Output Is:
+ ['Array', 1, False, 'List', 1.33, True]
# Array_(Indexs)
* arr = ["Array",1,False,"List",1.33,True]
* print(arr[3])
+ Output Is:
+ List
# Find the Length of List in Python_(len)
* list = ["HTML","CSS","JavaScript","EcmaScript","React Js","Redux","React Native","Firebase","Github","Bootstrap","Linux"]
* print(len(list))
+ Output Is:
+ 11
# Element Add Inside List_(append)
* arr = ["Array",1,False,"List",1.33,True]
* arr.append("React")
* print(arr)
+ Output Is:
+ ['Array', 1, False, 'List', 1.33, True, 'React']
# Multiples Elements Added Inside List
* arr1 = arr + ["JavaScript","HTML & CSS"]
* print(arr1)
+ Output Is:
+ ['Array', 1, False, 'List', 1.33, True, 'React', 'JavaScript', 'HTML & CSS']
# Get the largest number from a Numeric list_(max).
* largest = [65,34,23,67,98,56,87]
* print(max(largest))
+ Output Is:
* 98
+ Second Option:
* largest = [65,34,23,67,98,56,87]
* largest.sort()
* print(largest[-1])
+ Output Is:
+ 98
# List_(Array) Inside Insert Elements
* arr1.insert(2, "Redux")
* print(arr1)
+ Output Is:
+ ['Array', 1, 'Redux', False, 'List', 1.33, True, 'React', 'JavaScript', 'HTML & CSS']
# Array_(List) Inside Replace/Add Value
* arr1[5] = 1.34
* print(arr1)
+ Output Is:
+ ['Array', 1, 'Redux', False, 'List', 1.34, True, 'React', 'JavaScript', 'HTML & CSS']
# List_(Array) Inside Slice Elements
+ Slicing Is a Flexible tool to Build new Lists Out of an Existing List.
+ The Slice() Function returns a Slice Object that can use Used to Slice Strings, lists, tuple etc.
+ To Access a Range of items in a List, you need to Slice a List.
+ Syntex:
* arr2 = arr1[2 : 5] # 5 Means Index No 4 ('List')
* print(arr2)
+ Output Is:
+ ['Redux', False, 'List']
# Copy Element One Array To Second Array_(Short Cut):
* arr = ["Array",1,False,"List",1.33,True]
* arr.append("React")
* print(arr)
* arr3 = arr[:6]
* print(arr3)
+ Output Is:
+ ['Array', 1, False, 'List', 1.33, True, 'React']
+ ['Array', 1, False, 'List', 1.33, True]
# List_(Array) Inside (DELETE Method)
+ Definition & Usage:
+ The del keyword is used to delete objects. In Python everything is an object, so the del keyword can also be used to delete variables, lists, or parts of a list etc.
+ Syntex:
* arr = ["Array",1,False,"List",1.33,True]
* del arr[2]
* print(arr)
+ Output Is:
+ ['Array', 1, 'List', 1.33, True]
# List_(Array) Inside (Remove Method)
+ Definition & Usage:
+ remove() is an inbuilt function in Python programming language that removes a given object from the list. It does not return any value.
+ Remove the "Banana" element of the fruit list:
* fruits = ['Apple','Banana','Cherry']
* fruits.remove("Banana")
* print(fruits)
+ Output Is:
+ ['Apple', 'Cherry']
# List_(Array) Inside (Pop Method)
+ Definition & Usage:
+ Pop method is used to remove the last element of the list.
+ Pop () This remove the last element of the list
+ Remove the second element of the fruit list:
* fruits = ['Apple','Banana','Cherry']
* fruits.pop(1)
* print(fruits)
+ Output Is:
+ ['Apple', 'Cherry']
+ Second Example_(Push)
+ We can also use pop to cover values from one list to another:
* list5 = [1,2,3,4,5]
* list6 = list5.pop()
* print(list6)
+ Output Is:
+ 5
# List_(Array) Inside (Sort List Alphanumerically Method)
+ Definition & Usage:
+ List objects have a sort() method that will sort the list alphanumerically, ascending, by default:
+ Sort the list numerically:
* sort_method = [3,5,1,4,2,9,6,10,8,7]
* sort_method.sort()
* print(sort_method)
+ Output Is:
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ Sort the list alphabetically:
* sort_method = ["Banana","Apple","Cherry","Watermillon","Orange"]
* sort_method.sort()
* print(sort_method)
+ Output Is:
+ ['Apple', 'Banana', 'Cherry', 'Orange', 'Watermillon']
# List_(Array) Inside (Copy Method)
+ Definition & Usage:
+ You cannot copy a list simply by typing list2 = list1, because: list2 will only be a reference to list1, and changes made in list1 will automatically also be made in list2.
+ There are ways to make a copy, one way is to use the built-in List method copy().
+ Make a copy of a list with the copy() method:
* copy_method = ["Banana","Apple","Cherry","Watermillon","Orange"]
* copy_method1 = copy_method.copy()
* print(copy_method1)
+ Output Is:
+ ['Banana', 'Apple', 'Cherry', 'Watermillon', 'Orange']
# List_(Array) Inside (List Method)
+ Definition & Usage:
+ Another way to make a copy is to use the built-in method list().
+ Make a copy of a list with the list() method:
* list_method = ["Banana","Apple","Cherry","Watermillon","Orange"]
* list_method1 = list(list_method)
* print(list_method1)
+ Output Is:
+ ['Banana', 'Apple', 'Cherry', 'Watermillon', 'Orange']
# List_(Array) Inside (Sum Method)
+ Definition & Usage:
+ Add all items in a list, and return the result:
+ Example:
* Sum = [10,5,15,40,10,20]
* print(sum(Sum))
+ Output Is:
+ 100
# List_(Array) Inside (extend Method)
+ Definition & Usage:
+ Or you can use the extend() method, which purpose is to add elements from one list to another list:
+ Use the extend() method to add list2 at the end of list1:
* list1 = [1,2,3,4,5]
* list2 = [6,7,8,9,10]
* list1.extend(list2)
* print(list1)
+ Output Is:
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# List_(Array) Inside (Clear Method)
+ Definition & Usage:
+ Remove all elements from the fruits list:
* list = [1,2,3,4,5,6,7,8,9,10]
* print(list)
* list.clear()
* print(list)
+ Output Is:
+ [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
+ [] # This Is Empty List.
# Assignement No_(2):
+ Step No_(1):
* sub1 = int(input("Enter your English Subject Marks: "))
* sub2 = int(input("Enter your Physics Subject Marks: "))
* sub3 = int(input("Enter your Chemistry Subject Marks: "))
* sub4 = int(input("Enter your Bio Science Subject Marks: "))
* sub5 = int(input("Enter your Math Subject Marks: "))
* total = (sub1+sub2+sub3+sub4+sub5)/5
* if total >= 80 and total <= 100 :
* print("A+")
* elif total >= 70 and total < 80 :
* print("A")
* elif total >= 60 and total < 70 :
* print("B")
* elif total >= 50 and total < 60 :
* print("C")
* elif total >= 40 and total < 50 :
* print("D")