-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPythonCourseNew.php
More file actions
1406 lines (1334 loc) · 57.9 KB
/
PythonCourseNew.php
File metadata and controls
1406 lines (1334 loc) · 57.9 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
<?php
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<head>
<title></title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<style type="text/css">
@import url('https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap');
*{
margin: 0;
padding: 0;
box-sizing: border-box;
text-decoration: none;
font-family: sans-serif;
}
body{
background-color: #f3f5f9;
}
.wrapper{
position: relative;
margin: 10px;
}
.wrapper .sidebar{
width: auto;
height: auto;
margin-top: 1px;
padding: 30px 0px;
position: absolute;
background-color: white;
}
.c2{
padding: 15px;
border-bottom: 1px solid #bdb8d7;
border-bottom: 1px solid rgba(0,0,0,0.05);
border-top: 1px solid rgba(255,255,255,0.05);
list-style: none;
}
.c1{
color: black;
display: block;
}
.c2:hover{
background-color: lightgrey;
}
.wrapper .sidebar ul li:hover a{
color: #fff;
}
.wrapper .Content
{
float: right;
width:1180px;
min-height: 720px;
height:auto;
background-color:white;
margin-right:43px;
margin-top: 1px;
}
.y
{
text-align: center;
margin-top: 20px;
}
.basics
{
padding:10px;
display: block;
}
.basics p,h3{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.syntax,.data,.variables,.operator,.decision,.storage,.funt{
display: none;
}
.syntax p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.data p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.variables p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.course{
cursor: pointer;
width: 40px;
height: 40px;
position: relative;
display: inline-block;
margin-left: 240px;
height: auto;
margin-top:-2px;
}
.course i{
font-size: 40px;
}
.dd-content{
display: none;
position: absolute;
padding: 10px 20px;
background-color: white;
width: 200px;
box-shadow: 2px 2px 4px rgba(0,0,0,40);
box-sizing: 0 5px 25px rgba(0,0,0,0.1);
transition: 0.5s;
z-index: 1;
}
.course ul li{
list-style: none;
padding: 10px 0;
border-bottom: 1px solid rgba(0,0,0,0.01);
display: flex;
align-items: center;
}
.course ul li i{
max-width: 20px;
margin-right: 10px;
opacity: 0.5s;
transition: 0.5s;
}
.course ul li:hover i{
opacity: 1;
}
.course ul li a{
display: inline-block;
text-decoration: none;
color: #555;
font-weight: 500;
transition: 0.5s;
}
.course ul li:hover a{
color: #ff5d94;
}
.operator p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.storage p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 15px;
text-align: left;
}
.decision p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.storage p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.funt p,h2{
margin-left: 10px;
padding: 16px;
font-size: 19px;
}
.z
{
width: 100%;
padding-top: 20px;
height: 80px;
outline: none;
top: 0;
background-color: white;
}
.left
{
float: left;
width: 140px;
margin-left: 10px;
}
.g
{
float: right;
margin-right: 60px;
margin-bottom: 25px;
margin-top: -8px;
}
.x71
{
background-color:rgb(153, 204, 255);
color: white;
padding: 8px 18px;
margin: 8px 0;
border: none;
cursor: pointer;
width: auto;
border-radius: 2px;
}
.x71:hover
{
opacity: 0.8;
}
.dropdown{
float: right;
cursor: pointer;
width: 40px;
height: 40px;
position: relative;
display: inline-block;
margin-right: 240px;
height: auto;
}
.dropdown i{
font-size: 40px;
}
.dropdown-content {
display: none;
position: absolute;
top: 50px;
padding: 10px 20px;
background-color: lightgrey;
width: 200px;
box-sizing: 0 5px 25px rgba(0,0,0,0.1);
transition: 0.5s;
z-index: 1;
border-radius:15px;
}
.dropdown .dropdown-content::before{
content: '';
position: absolute;
top: -5px;
right: 160px;
width: 20px;
height: 20px;
transform: rotate(45deg);
background-color: lightgrey;
}
.dropdown ul li{
list-style: none;
padding: 10px 0;
border-top: 1px solid rgba(0,0,0,0.1);
display: flex;
align-items: center;
}
.dropdown ul li i{
max-width: 20px;
margin-right: 10px;
opacity: 0.5s;
transition: 0.5s;
}
.dropdown ul li:hover i{
opacity: 1;
}
.dropdown ul li a{
display: inline-block;
text-decoration: none;
color: #555;
font-weight: 500;
transition: 0.5s;
}
.dropdown ul li:hover a{
color: #ff5d94;
}
.show {display: block;}
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0,0); /* Fallback color */
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
padding-top: 60px;
}
.modal-content {
background-color: #fefefe;
margin: 5% auto 15% auto; /* 5% from the top, 15% from the bottom and centered */
border: 1px solid #888;
width: 30%;
height:auto; /* Could be more or less, depending on screen size */
}
.container {
padding: 16px;
}
span.psw {
float: right;
padding-top: 16px;
}
.r1,.r2
{
width:100%;
padding:10px 15px;
margin:5px 0px;
border: 1px solid lightgrey;
outline: none;
border-radius: 2px;
font-size: 17px;
}
::placeholder
{
text-align: center;
}
/* The Close Button (x) */
.close {
position: absolute;
right: 30px;
top: 0;
color: #000;
font-size: 35px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: red;
cursor: pointer;
}
.submit-btn
{
background-color:#4CAF50;
color: white;
width: 100%;
padding: 10px 30px;
display: block;
outline: none;
margin:auto;
border:none;
cursor: pointer;
font-size: 20px;
}
a
{
text-decoration: none;
}
.slide-controls
{
width:100%;
margin: 35px auto;
position: relative;
box-shadow: 0 0 20px 9px #ff61241f;
}
.toggle-btn
{
text-align: center;
padding: 10px 45px;
cursor: pointer;
background: transparent;
border:0;
outline: none;
position: relative;
font-size: 20px;
}
#btn
{
text-align: center;
position: absolute;
width:50%;
height: 100%;
background: linear-gradient(to right,lightgrey,lightgrey);
transition: .5s;
}
.v
{
text-align: center;
color: white;
padding-top: 200px;
font-size: 45px;
}
.footer
{
padding:50px;
color: #fff;
background-color: #011c39;
}
#login
{
left: 50%;
}
.footer p{
text-align: center;
}
.footer a{
text-decoration: none;
}
.footer-bottom{
text-align: center;
color: #999;
margin-bottom:-30px;
}
.socials a{
background: #364a62;
width: 40px;
height: 40px;
display: inline-block;
}
.socials a i{
color: #e7f2f4;
padding: 10px 12px;
font-size: 20px;
}
.imgcontainer {
position: relative;
}
.animate {
-webkit-animation: animatezoom 0.6s;
animation: animatezoom 0.6s
}
@-webkit-keyframes animatezoom {
from {-webkit-transform: scale(0)}
to {-webkit-transform: scale(1)}
}
@keyframes animatezoom {
from {transform: scale(0)}
to {transform: scale(1)}
}
/* Change styles for span and cancel button on extra small screens */
@media screen and (max-width: 300px) {
span.psw {
display: block;
float: none;
}
img.avatar {
width: 40%;
border-radius: 50%;
}
</style>
<body>
<div class="z">
<div class="left">
<a href="newproject.php"><img src="https://www.simplilearn.com/ice9/new_logo.svgz" style="width: 140px;margin-left: 10px;cursor: pointer;">
</div></a>
<div class="course">
<input type="button" onclick="mycourse()" class="x71" value="Courses" name="">
<ul id='myDrop' class='dd-content'>
<li><a href='coursesection.php'>C++</a></li>
<li><a href='javacoursepage.php'>Java</a></li>
<li><a href='sql.php' >Sql</a></li>
<li><a href='phpcourse.php' >Php</a></li>
<li><a href='PythonCourseNew.php' >Python</a></li>
</ul>
</div>
<?php if(!isset($_SESSION['name']))
echo " <div class='g' id='first'>
<button class='x71' onclick='loginform()' style='width:auto;' type='submit'>Login</button>
</div> " ?>
<?php if(isset($_SESSION['name']))
echo " <div class='dropdown' id='third'>
<i onclick='myFunction()' class='fa fa-user-circle-o'></i>
<ul id='myDropdown' class='dropdown-content'>
<li><i class='fa fa-user' style='font-size:15px;'></i> <a href='profilepage.php'>my profile</a></li>
<li><i class='fa fa-edit' style='font-size:15px;'></i> <a href='editprofile.php'>Edit profile</a></li>
<li><i class='fa fa-sign-out' style='font-size:15px;'></i> <a href='newlogout.php' id='second' >Logout</a></li>
</ul>
</div>";?>
</div>
<div id="id01" class="modal">
<div class="modal-content animate">
<div class="imgcontainer">
<span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span>
</div>
<div class="wrapper1" style="width:70%;height:70%;margin-left: 60px;padding: 30px;border-radius:5px;overflow: hidden;">
<div class="title-text" style="display: flex;width: 200%">
<div class="title login" style="width: 50%;font-size:35px;font-weight: 600;text-align: center">Login Form</div>
</div>
<div class="form-container" style="width: 100%;overflow: hidden;">
<div class="form-inner" style="display: flex;width: 200%;">
<form action="newlogin.php" method="post" class="login" id="login" style="width:50%;">
<div style="height: 50px;width: 90%;margin-top: 20px;padding-top: 2px;padding-bottom: 2px;">
<input type="text" class="r1" placeholder="username or email" name="name" required="">
</div>
<div style="height: 50px;width: 90%;margin-top: 20px;">
<input type="password" class="r2" placeholder="Password" name="password" required="">
</div><br><br>
<div class="pass-link">
<a href="#">Forgot password?</a><br><br>
</div>
<div>
<input type="submit" class="submit-btn" value="Login" onclick="account()">
</div><br>
<div class="signup-link">Not a member? <a href="http://localhost/signup.php">Signup now</a></div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="wrapper">
<div class="sidebar">
<ul>
<li class="c2"><a href="#" class="c1" onclick="basics()">python Programming Language</a></li>
<li class="c2"><a href="#" class="c1" onclick="syntax()">Basic Concepts of python</a></li>
<li class="c2"><a href="#" class="c1" onclick="datatype()">Datatypes and Modifiers in python </a></li>
<li class="c2"><a href="#" class="c1" onclick="variables()">Variables</a></li>
<li class="c2"><a href="#" class="c1" onclick="operator()">Operators</a></li>
<li class="c2"><a href="#" class="c1" onclick="decision()">Decision making</a></li>
<!-- <li class="c2"><a href="#" class="c1" onclick="storage()">Storage classes</a></li> -->
<li class="c2"><a href="#" class="c1" onclick="fun()">functions</a></li>
<li class="c2"><a href="https://docs.google.com/forms/d/e/1FAIpQLSeoLEbfMA3jcNhha3ulVuREdr-b13ljAZHLN92nS9y_dfmyWQ/viewform?usp=sf_link" target="_blank" class="c1" >Quiz-Python</a></li>
</ul>
</div>
<div class="Content" style="font-family: sans-serif;">
<div class="basics" id="v">
<h1 class="y">Introduction to Python </h1>
<img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20200711122552/Python-Programming-Language.png" style="margin-left: 100px;margin-top:40px;width: 950px;height: 300px;">
<p>Python is a high-level, general-purpose and a very popular programming language. Python programming language (latest Python 3) is being used in web development, Machine Learning applications, along with all cutting edge technology in Software Industry. Python Programming Language is very well suited for Beginners, also for experienced programmers with other programming languages like C++ and Java. </p>
<p>This specially designed Python tutorial will help you learn Python Programming Language in most efficient way, with the topics from basics to advanced (like Web-scraping, Django, Deep-Learning, etc.) with examples.
</p>
<h3>Below are some facts about Python Programming Language: </h3>
<ol>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;" >Python is currently the most widely used multi-purpose, high-level programming language.</li>
<br><li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Python allows programming in Object-Oriented and Procedural paradigms.</li>
<br><li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Python programs generally are smaller than other programming languages like Java. Programmers have to type relatively less and indentation requirement of the language, makes them readable all the time. </li>
<br><li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Python language is being used by almost all tech-giant companies like – Google, Amazon, Facebook, Instagram, Dropbox, Uber… etc.
</li>
<br><li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">The biggest strength of Python is huge collection of standard library which can be used for the following:
<ul>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Machine Learning</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">GUI Applications (like Kivy, Tkinter, PyQt etc. )</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Web frameworks like Django (used by YouTube, Instagram, Dropbox)</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Image processing (like OpenCV, Pillow)</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Web scraping (like Scrapy, BeautifulSoup, Selenium)</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Test frameworks</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Multimedia</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Scientific computing</li>
<li style="margin-left: 40px;color:black;font-size: 18px;padding: 15px;">Text processing and many more..</li>
</ul>
</li>
</ol>
</div>
<div class="syntax" id="syn">
<h1 class="y">Basic Concepts of Python </h1>
<h2>Python 3 basics</h2>
<p>Python was developed by Guido van Rossum in the early 1990s and its latest version is 3.7.1, we can simply call it as Python3. Python 3.0 was released in 2008. and is interpreted language i.e it’s not compiled and the interpreter will check the code line by line. This article can used to learn very basics of Python programming language. </p>
<h2>Syntax and Structure of Python program</h2>
<p>So before moving on further.. let’s do the most popular ‘HelloWorld’ tradition 😛 and hence compare Python’s Syntax with C, C++, Java ( I have taken these 3 because they are most famous and mostly used languages). </p>
<h2>First Python program </h2>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# Python code for "Hello World" <br>
# nothing else to type...see how simple is the syntax. <br><br>
print("Hello World")
</div><br>
<p><b>Note:</b> Please note that Python for its scope doesn’t depend on the braces ( { } ), instead it uses indentation for its scope.</p>
<p>Let’s analyze the script line by line.</p>
<p>
<b>Line 1: [# Script Begins] </b>In Python, comments begin with a #. This statement is ignored by the interpreter and serves as documentation for our code.<br><br>
<b>Line 2: [print(“hello..!”)]</b> To print something on the console, print() function is used. This function also adds a newline after our message is printed(unlike in C). Note that in Python 2, “print” is not a function but a keyword and therefore can be used without parentheses. However, in Python 3, it is a function and must be invoked with parentheses.<br><br>
<b>Line 3: [# Script Ends]</b> This is just another comment like in Line 1.
</p>
<h2>Comments in Python Program </h2>
<p>For single line comments, use // before mentioning comment, like </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
print("Hello World") // This is single line comment
</div>
<p>For multiple line comment, enclose the comment between /* and */</p>
<div style="background-color: lightgrey;margin-left: 400px;width:200px;padding: 15px;">
/*this is<br>
a multiple line<br>
comment */<br>
</div>
</div>
<div class="data" id="dtype">
<h1 class="y">Datatypes and Modifiers in Python</h1>
<p>Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.<br><br>
Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, data types are actually classes and variables are instance (object) of these classes.<br>
<ul>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Numeric</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Sequence Type</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Boolean</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Set</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Dictionary</li>
</ul>
</p>
<img src="https://media.geeksforgeeks.org/wp-content/uploads/20191023173512/Python-data-structure.jpg" style="margin-left: 250px;margin-top:40px;width: 700px;height: 400px;">
<h2>Numeric</h2>
<p>In Python, numeric data type represent the data which has numeric value. Numeric value can be integer, floating number or even complex numbers. These values are defined as int, float and complex class in Python.<br>
<br>
<ul>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;"><b>Integers –</b> This value is represented by int class. It contains positive or negative whole numbers (without fraction or decimal). In Python there is no limit to how long an integer value can be.</li><br><br>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;"><b>Float –</b> This value is represented by float class. It is a real number with floating point representation. It is specified by a decimal point. Optionally, the character e or E followed by a positive or negative integer may be appended to specify scientific notation.</li><br><br>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;"><b>Complex Numbers –</b> Complex number is represented by complex class. It is specified as (real part) + (imaginary part)j. For example – 2+3j</li>
</ul>
</p>
<h2>Sequence Type</h2>
<p>In Python, sequence is the ordered collection of similar or different data types. Sequences allows to store multiple values in an organized and efficient fashion. There are several sequence types in Python –</p>
<ul>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">String</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">List</li>
<li style="margin-left: 80px;color:#696969;font-size: 18px;padding: 5px;">Tuple</li>
</ul>
<p><h3>1) String</h3></p>
<p>In Python, Strings are arrays of bytes representing Unicode characters. A string is a collection of one or more characters put in a single quote, double-quote or triple quote. In python there is no character data type, a character is a string of length one. It is represented by str class.</p>
<p><h4>Creating String</h4></p>
<p>Strings in Python can be created using single quotes or double quotes or even triple quotes.</p>
<p><h4>Accessing elements of String</h4></p>
<p>In Python, individual characters of a String can be accessed by using the method of Indexing. Indexing allows negative address references to access characters from the back of the String, e.g. -1 refers to the last character, -2 refers to the second last character and so on.</p>
<p><h3>2) List</h3></p>
<p>Lists are just like the arrays, declared in other languages which is a ordered collection of data. It is very flexible as the items in a list do not need to be of the same type.</p>
<p><h4>Creating List</h4></p>
<p>Lists in Python can be created by just placing the sequence inside the square brackets[].</p>
<p><h4>Accessing elements of List</h4></p>
<p>In order to access the list items refer to the index number. Use the index operator [ ] to access an item in a list. In Python, negative sequence indexes represent positions from the end of the array. Instead of having to compute the offset as in List[len(List)-3], it is enough to just write List[-3]. Negative indexing means beginning from the end, -1 refers to the last item, -2 refers to the second-last item, etc.</p>
<p><h3>3) Tuple</h3></p>
<p>Just like list, tuple is also an ordered collection of Python objects. The only difference between type and list is that tuples are immutable i.e. tuples cannot be modified after it is created. It is represented by tuple class.</p>
<p><h4>Creating Tuple</h4></p>
<p>In Python, tuples are created by placing a sequence of values separated by ‘comma’ with or without the use of parentheses for grouping of the data sequence. Tuples can contain any number of elements and of any datatype (like strings, integers, list, etc.).<br><br>
<b>Note:</b> Tuples can also be created with a single element, but it is a bit tricky. Having one element in the parentheses is not sufficient, there must be a trailing ‘comma’ to make it a tuple.
<br><br>
<b>Note –</b> Creation of Python tuple without the use of parentheses is known as Tuple Packing.</p>
<p><h4>Accessing elements of Tuple</h4></p>
<p>In order to access the tuple items refer to the index number. Use the index operator [ ] to access an item in a tuple. The index must be an integer. Nested tuples are accessed using nested indexing.</p>
<p><h2>Boolean</h2></p>
<p>Data type with one of the two built-in values, True or False. Boolean objects that are equal to True are truthy (true), and those equal to False are falsy (false). But non-Boolean objects can be evaluated in Boolean context as well and determined to be true or false. It is denoted by the class bool.<br><br>
<b>Note –</b> True and False with capital ‘T’ and ‘F’ are valid booleans otherwise python will throw an error.</p>
<h2>Set</h2>
<p>In Python, Set is an unordered collection of data type that is iterable, mutable and has no duplicate elements. The order of elements in a set is undefined though it may consist of various elements.</p>
<p><h3>Creating Sets</h3></p>
<p>Sets can be created by using the built-in set() function with an iterable object or a sequence by placing the sequence inside curly braces, separated by ‘comma’. Type of elements in a set need not be the same, various mixed-up data type values can also be passed to the set.<br><br></p>
<p><h3>Accessing elements of Sets</h3></p>
<p>Set items cannot be accessed by referring to an index, since sets are unordered the items has no index. But you can loop through the set items using a for loop, or ask if a specified value is present in a set, by using the in keyword.</p>
<h2>Dictionary</h2>
<p>Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. Key-value is provided in the dictionary to make it more optimized. Each key-value pair in a Dictionary is separated by a colon :, whereas each key is separated by a ‘comma’.<br><br>
</p>
<p><h3>Creating Dictionary</h3></p>
<p>In Python, a Dictionary can be created by placing a sequence of elements within curly {} braces, separated by ‘comma’. Values in a dictionary can be of any datatype and can be duplicated, whereas keys can’t be repeated and must be immutable. Dictionary can also be created by the built-in function dict(). An empty dictionary can be created by just placing it to curly braces{}.<br><br>
</p>
<p><b>Note –</b> Dictionary keys are case sensitive, same name but different cases of Key will be treated distinctly.<br><br></p>
<p><h3>Accessing elements of Dictionary</h3></p>
<p>In order to access the items of a dictionary refer to its key name. Key can be used inside square brackets. There is also a method called get() that will also help in accessing the element from a dictionary.</p>
</div>
<div class="variables" id="variable">
<h1 class="y">Variables</h1>
<p>Python is not “statically typed”. We do not need to declare variables before using them, or declare their type. A variable is created the moment we first assign a value to it. </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
#!/usr / bin / python <br><br>
# An integer assignment <br>
age = 45 <br><br>
# A floating point <br>
salary = 1456.8 <br><br>
# A string <br>
name = "John" <br><br>
print(age) <br>
print(salary) <br>
print(name) <br>
</div>
<h2>Basic types of Variables </h2>
<p>Each variable while declaration must be given a datatype, on which the memory
assigned to the variable depends. Following are the basic types of variables,</p>
<table style="width:50%;margin-left: 200px;">
<tr>
<th>Datatype</th>
<th>description</th>
</tr>
<tr>
<td>bool</td>
<td>For variable to store boolean values( True or False ) </td>
</tr>
<tr>
<td>char</td>
<td>For variables to store character types.
</td>
</tr>
<tr>
<td>int</td>
<td>for variable with integral values</td>
</tr>
<tr>
<td>float and double</td>
<td> for variables with large and floating point values </td>
</tr>
</table><br><br>
<h2>Scope of Variables </h2>
<p>All the variables have their area of functioning, and out of that boundary they
don't hold their value, this boundary is called scope of the variable. For most of
the cases its between the curly braces,in which variable is declared that a
variable exists, not outside it. </p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Global Variables</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Loacal Variables</li>
</ul>
<h2>Global variables and Local variables</h2>
<p>Global variables are the one that are defined and declared outside a function and we need to use them inside a function.<br><br></p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# This function uses global variable s <br>
def f(): <br>
print(s) <br>
<br>
# Global scope <br>
s = "I love python"<br>
f() <br><br>
<b>Output:</b><br><br>
I love python
</div>
<p>The variable s is defined as the string “I love python” before we call the function f(). The only statement in f() is the “print s” statement. As there is no local s, the value from the global s will be used.</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# This function has a variable with <br>
# name same as s. <br>
def f(): <br>
s = "Me too."<br>
print(s) <br>
<br>
# Global scope <br>
s = "I love python" <br>
f() <br>
print(s) <br>
Output:<br>
<br>
Me too.<br>
I love python<br>
</div>
<p>If a variable with the same name is defined inside the scope of function as well then it will print the value given inside the function only and not the global value.</p>
</div>
<div class="operator" id="op">
<h1 class="y">Operators in Python</h1>
<p>Operators are special type of functions, that takes one or more arguments and
produces a new value. For example : addition (+), substraction (-), multiplication
(*) etc, are all operators. Operators are used to perform various operations on
variables and constants. </p>
<h2>Types of operators</h2>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Assignment Operator </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Mathematical Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Relational Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Logical Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise Operators </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Shift Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Unary Operators</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Ternary Operator </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Comma Operator</li>
</ul>
<h2>Assignment Operator (=) </h2>
<p>Operates '=' is used for assignment, it takes the right-hand side (called rvalue)
and copy it into the left-hand side (called lvalue). Assignment operator is the
only operator which can be overloaded but cannot be inherited. </p>
<h2>Mathematical Operators </h2>
<p>
There are operators used to perform basic mathematical operations. Addition
(+) , subtraction (-) , diversion (/) multiplication (*) and modulus (%) are the basic
mathematical operators. Modulus operator cannot be used with floating-point
numbers.<br><br>
pythonalso use a shorthand notation to perform an operation and
assignment at same type. Example,
</p>
<div style="background-color: lightgrey;margin-left: 70px;width:1000px;padding: 15px;">
= Assign value of right side of expression to left side operand x = y + z<br><br>
+= Add AND: Add right side operand with left side operand and then assign to left operand a+=b a=a+b<br><br>
-= Subtract AND: Subtract right operand from left operand and then assign to left operand a-=b a=a-b<br><br>
*= Multiply AND: Multiply right operand with left operand and then assign to left operand a*=b a=a*b<br><br>
/= Divide AND: Divide left operand with right operand and then assign to left operand a/=b a=a/b<br><br>
%= Modulus AND: Takes modulus using left and right operands and assign result to left operand a%=b a=a%b<br><br>
//= Divide(floor) AND: Divide left operand with right operand and then assign the value(floor) to left operand a//=b a=a//b<br><br>
**= Exponent AND: Calculate exponent(raise power) value using operands and assign value to left operand a**=b a=a**b<br><br>
&= Performs Bitwise AND on operands and assign value to left operand a&=b a=a&b<br><br>
|= Performs Bitwise OR on operands and assign value to left operand a|=b a=a|b<br><br>
^= Performs Bitwise xOR on operands and assign value to left operand a^=b a=a^b<br><br>
>>= Performs Bitwise right shift on operands and assign value to left operand a>>=b a=a>>b<br><br>
<<= Performs Bitwise left shift on operands and assign value to left operand a <<= b a= a << b<br><br>
</div>
<h2>Relational Operators </h2>
<p>
These operators establish a relationship between operands. The relational
operators are : less than (<) , grater thatn (>) , less than or equal to (<=), greater
than equal to (>=), equivalent (==) and not equivalent (!=).<br><br>
You must notice that assignment operator is (=) and there is a relational
operator, for equivalent (==). These two are different from each other, the
assignment operator assigns the value to any variable, whereas equivalent
operator is used to compare values, like in if-else conditions, Example
</p>
<div style="background-color: lightgrey;margin-left: 200px;width:800px;padding: 15px;">
> Greater than: True if left operand is greater than the right x > y<br><br>
< Less than: True if left operand is less than the right x < y<br><br>
== Equal to: True if both operands are equal x == y<br><br>
!= Not equal to - True if operands are not equal x != y<br><br>
>= Greater than or equal to: True if left operand is greater than or equal to the right x >= y<br><br>
<= Less than or equal to: True if left operand is less than or equal to the right x <= y<br><br>
</div>
<h2>Logical Operators</h2>
<p>
The logical operators are AND (&&) and OR (||). They are used to combine two
different expressions together.<br><br>
If two statement are connected using AND operator, the validity of both
statements will be considered, but if they are connected using OR operator,
then either one of them must be valid. These operators are mostly used in
loops (especially while loop) and in Decision making.
</p>
<h2>Bitwise Operators</h2>
<p>
There are used to change individual bits into a number. They work with only
integral data types like char, int and long and not with floating point values.</p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise AND operators &</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Bitwise OR operator |</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">And bitwise XOR operator ^
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">And, bitwise NOT operator ~</li>
</ul>
<p>They can be used as shorthand notation too, & = , |= , ^= , ~= etc</p>
<h2>Shift Operators </h2>
<p>
Shift Operators are used to shift Bits of any variable. It is of three types, </p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Left Shift Operator <<</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;"> Right Shift Operator >></li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Unsigned Right Shift Operator >>>
</li>
</ul>
</div>
<div class="decision" id='dec'>
<h1 class="y">Decision making in python - if, else and else if</h1>
<p>Decision making is about deciding the order of execution of statements based
on certain conditions or repeat a group of statements until certain specified
conditions are met. python handles decision-making by supporting the following
statements,
</p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">if statement </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">conditional operator statement
</li>
</ul>
<h2>Decision making with if statement </h2>
<p>The if statement may be implemented in different forms depending on the
complexity of conditions to be tested. The different forms are, </p>
<ul>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Simple if statement </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">if....else statement </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Nested if....else statement
</li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">if-elif-else ladder </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Short Hand if statement </li>
<li style="margin-left: 40px;color:#696969;font-size: 18px;padding: 5px;">Short Hand if-else statement </li>
</ul>
<h2>Simple if statement </h2>
<p>if statement is the most simple decision making statement. It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not. </p>
<p><b>Syntax:</b></p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
if condition:<br>
statement1<br>
statement2<br>
<br>
# Here if the condition is true, if block <br>
# will consider only statement1 to be inside <br>
# its block.<br>
</div><br><br>
<p>If the expression is true, then 'statement-inside' will be executed, otherwise
'statement-inside' is skipped and only 'statement-outside' will be executed.</p>
<h2>Flowchart</h2>
<img src="https://media.geeksforgeeks.org/wp-content/uploads/if-statement.jpg" style="margin-left: 450px;margin-top:40px;width: 350px;height: 400px;">
<p>Example :</p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# python program to illustrate If statement <br>
<br>
i = 10<br>
if (i > 15): <br>
print ("10 is less than 15") <br>
print ("I am Not in if") <br><br><br>
<b>Output:</b><br>
<br>
I am Not in if<br>
</div>
<h2>if...else statement</h2>
<p>The if statement alone tells us that if a condition is true it will execute a block of statements and if the condition is false it won’t. But what if we want to do something else if the condition is false. Here comes the else statement. We can use the else statement with if statement to execute a block of code when the condition is false.<br><b>Syntax:</b> </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
if (condition):<br>
# Executes this block if<br>
# condition is true<br>
else:<br>
# Executes this block if<br>
# condition is false<br>
</div>
<p>If the 'expression' is true or returns true, then the 'statement-block1' will get
executed, else 'statement-block1' will be skipped and 'statement-block2' will be
executed.<br><br>
</p>
<h2>Flowchart</h2>
<img src="https://media.geeksforgeeks.org/wp-content/uploads/if-else.jpg" style="margin-left: 450px;margin-top:40px;width: 350px;height: 400px;">
<p><b>Example:</b></p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# python program to illustrate If else statement <br>
#!/usr/bin/python <br>
<br>
i = 20; <br>
if (i < 15): <br>
print ("i is smaller than 15") <br>
print ("i'm in if Block") <br>
else: <br>
print ("i is greater than 15") <br>
print ("i'm in else Block")<br>
print ("i'm not in if and not in else Block") <br><br><br>
<b>Output:</b><br>
<br>
i is greater than 15<br>
i'm in else Block<br>
i'm not in if and not in else Block<br>
</div>
<h2>Nested if....else statement </h2>
<p>A nested if is an if statement that is the target of another if statement. Nested if statements means an if statement inside another if statement. Yes, Python allows us to nest if statements within if statements. i.e, we can place an if statement inside another if statement.<br><b>Syntax:</b> </p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
if (condition1):<br><br>
# Executes when condition1 is true<br><br>
if (condition2): <br><br>
# Executes when condition2 is true<br><br>
# if Block is end here<br><br>
# if Block is end here
</div>
<p><b>Flow chart:-</b></p><img src="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20200710163548/Nested_if.jpg" style="margin-left: 450px;margin-top:40px;width: 350px;height: 400px;">
<br><br><p><b> Example:</b></p>
<div style="background-color: lightgrey;margin-left: 400px;width:400px;padding: 15px;">
# python program to illustrate nested If statement <br><br>
#!/usr/bin/python <br><br>
i = 10<br><br>
if (i == 10):<br><br>
# First if statement<br><br>
if (i < 15):<br><br>
print ("i is smaller than 15") <br><br>
# Nested - if statement <br><br>
# Will only be executed if statement above <br><br>
# it is true <br><br>
if (i < 12): <br><br>
print ("i is smaller than 12 too") <br><br>
else: <br><br>
print ("i is greater than 15") <br><br><br>
<b>Output:</b><br><br>
<br><br>
i is smaller than 15<br><br>
i is smaller than 12 too<br><br>
</div>
<h2>if-elif-else ladder</h2>
<p>Here, a user can decide among multiple options. The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed.</p>
<p><b>Syntax:-</b>