-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIntroduction.txt
More file actions
19511 lines (16998 loc) · 973 KB
/
Copy pathIntroduction.txt
File metadata and controls
19511 lines (16998 loc) · 973 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
Python:
--------
Guido van Rossum is the inventor of Python Programming Language,
he worked as an implementer on a team building a language called ABC at "Centrum Wiskunde Informatica" (CWI).
In the year 1989, he started to prepare a Simple Scripting Language to resolve the problems of ABC programming language, as part of this,
he prepared a simple virtual machine, a simple parser, and a simple runtime with various parts of ABC programming Language.
Guido van Rossum has given name to this programming Language as "Python"
not by thinking Snakes name, He has given name "Python" to the programming
language as he is a big fan of "Monty Python's Flying Circus" TV Show.
Guido van Rossum has introduced the first version of Python in February 1991
with the Version 0.9.0 with the features like Exception Handling, Functions,
and the core data types of list, dict, str and so on.
Python version 1.0 was released in January 1994,
It includes the major new features like functional programming tools like lambda,
map, filter and reduce,....
In October 2000, Python 2.0 was introduced,
It has included the features like list comprehensions,
a full garbage collector and supporting unicode.....
In December 2008, Python 3.0 version was introduced ,
it is also called as “Python 3000” or “Py3K”, it includes the following enhancements.
1. Print is now a function
2. Views and iterators instead of lists
3. The rules for ordering comparisons have been simplified.
4. There is only one integer type left, i.e. int. long is int as well.
5. The division of two integers returns a float instead of an integer.
6. Text Vs. Data Instead Of Unicode Vs. 8-bit
and some other Syntax changes.
Note: Python 3.0 version is not backward Compatible with Python 2.0 version.
The latest Version of the Python is "Python 3.7.2" released in 23rd Dec 2018,
it includes the following enhancements.
1. Legacy C Locale Coercion
2. Forced UTF-8 Runtime Mode
3. Built-in breakpoint()
4. New C API for Thread-Local Storage
5. Customization of Access to Module Attributes
6. New Time Functions With Nanosecond Resolution
7. Show DeprecationWarning in __main__
8. Core Support for typing module and Generic Types
9. Hash-based .pyc Files
and some other syntax changes.
Course Content:
---------------
Core Python
===========
1. Introduction
2. Language Fundamentals
3. Operators
4. Flow Control
5. String Data Type
6. List Data Structure
7. Tuple Data Structure
8. Set Data Structure
9. Dictionary Data Structure
10. Functions
11. Modules
12. Packages
13. Pattern Programs
Advanced Python
==============
14. OOPs
15. Exception Handling
16. File Handling
17. Multi Threading
18. Python Database Connectivity[PDBC]
19. Regular Expressions & Web Scraping
20. Decorator Functions
21. Generator Functions
22. Assertions
23. Python Logging
24. Python-GUI[TKinter]
25. Python-Distributed Applications[RPyC].
1. Introduction
-----------------
1. Python History
2. Differences between Python and Others[C, C++ and JAVA]:
-----------------------------------------------------------
1. Python is very simple Programming language when compared with C, C++ and JAVA:
---------------------------------------------------------------------------------
1. Simple Syntaxes in Python
2. Readability is good in Python
3. Less no of Instructions in Python
4. Easy to write programs and easy to execute applications.
5. Not required to specify data types explicitly in python.
6. Less Error prone programming language.
2. C and C++ are static Programming Languages
but JAVA and Python are Dynamic Programming Languages:
------------------------------------------------------------------------
C and C++ are allocating memory for the data at compilation time, so that,
C and C++ are Static programming languages.
JAVA is able to allow memory allocation for the data at runtime , so that,
JAVA is dynamic programming Language.
In case of Python, no sperate process for compilation and execution, in Python every
thing is going on at runtime only including memory allocation, so that,
Python is bydefault Dynamic Programming Language.
3. Pre-Processor is required in C and C++, but,
Pre-Processor is not required in Java and Python:
------------------------------------------------------------------------
In C and C++, Preprocessing activities are required like evaluating #include statements,
#define statements,... so Pre-processor is required in C and C++.
In JAVA and Python , Pre-Processing activities are not existed , so that,
Pre-Processor is not required in Java and Python.
4. C and C++ are Platform Dependent programming Languages , but,
JAVA and Python are platform Independent Programming Language:
-------------------------------------------------------------------------
C and C++ are platform dependent programming Languages , because, C and C++
allows their applications to perform compilation and execution
on the same Operating System.
Java is a platform Independent Programming language, because, JAVA allows its
applications to perform compilation is on one Operating System and execution is on
another Operating System.
Note: Java is a platform Independent Programming Language because of JVMs only,
but, JVM is platform dependent.
Python is a Platform Independent Programming Language, because, Python allows its
applications to run under all the Operating Systems like Windows, Linux, Unix,
Solaries,..... with out having modifications.
Note: Python is a platform Independent Programming Language because of PVMs
only, but, PVM is platform dependent tool, not only PVM,
the complete Python Software is platform Dependent.
5. C is Procedure Oriented Programming Language, C++ &Java are Object Oriented
Programming languages , Python is both Procedure oriented & Object Oriented
Programming language:
----------------------------------------------------------------------------------
C is a procedure oriented programming language, because, C programming language is
using function/Procedure orented features like Functions, Lambdas,......
C++ and Java are Object Oriented Programming languages, because, C++ and Java are
following Object Oriented features like Class, Object, Encapsulation, Abstraction,
Inheritance, Polymorphism,.......
Python is both Procedure Oriented and Object Oriented Programming Language,
because, Python is following Procedure oriented features like Functions, Lambdas,
Filters, map, reduce,..... and Object Oriented Features like class, object, encapsulation,
abstraction, Inheritance, Polymorphism,.....
6. C, C++ and Java are statically Typed programming Languages, but,
Python is dynamically Typed Programming Language:
---------------------------------------------------------------------------------
If we represent Data as per the types in any Programming Language then that
Programming Language is called as Typed Programming language.
C, C++ and Java are Statically Typed Programming Languages, because, in C, C++ and
Java applications before representing data first we must confirm which type of data
we are representing.
EX:
1. int i = 10; ---> Valid
2. int i;
i = 10; ---> Valid
3. i = 10; --> Invalid
Python is dynamically Typed Programming Language, because, in python applications ,
data types will be confirmed internally after providing data, not before providing data.
EX:
i = 10;
print(type(i)) ---> int
EX:
f = 22.22
type(f) ----> float
7. C++ is using Destructors to destroy objects, Java is using Garbage Collector to
destroy objects, but, Python is using both Destructors methods and Garbage Collector
to destroy objects:
-----------------------------------------------------------------------------------
In general, In Object Oriented Programming Languages , it is convention to represent
data in the form of Objects as per Object Oriented features. In Object Oriented
Programming Languages, to create objects we will use "Constructors" and to destroy
objects we will use "Destructors".
In C++ , there is no Garbage Collector kind of component to destroy objects , so that,
in C++ applications, developers must destroy objects explicitly, to destroy objects
explicitly developers must use "Destructors" feature in C++.
In Java, developers are not responsible to destroy objects, because, JAVA has an
implicit component in the form of "Garbage Collector" to destroy objects, so that,
Destructors are not required in java.
In Python, Both Destructor method and and Garbage Collector are existed to destroy
objects. In general, we will use destructors methods for explicit object destruction and
Python will use Garbage Collector for implicit Objects destruction.
Note: In Python applications, we will use destructor methods to include a set of
instructions inorder to execute while destroying objects.
8.C++ and Python are allowing Multiple Inheritance, but, JAVA is not allowing
Multiple Inheritance:
--------------------------------------------------------------------------------
Inheritance: it is a relation between classes, it will provide variables and functions from
one class[parent Class/Base Class/Super class] to another class[ Chaild class / Derived
Class/ Sub class] inorder to improve Code Reusability.
The main advantage of Inheritance is "Code Reusability".
Initially, there are two types of Inheritances.
1. Single Inheritance
2. Multiple Inheritance
By combining single and multiple inheritances three more inheritances are defined.
3. Multi Level Inheritance
4. Hierarchical Inheritance
5. Hybrid Inheritance.
1. Single Inheritance:
-----------------------
It is a relation between classes, it will bring variables and methods from only one super
class to one or more no of sub classes.
2. Multiple Inheritance
------------------------
It is a relation between classes, it will bring variables and methods from more than one
super class to one or more no of sub classes.
In Java, multiple inheritance is not possible , because, in Java applications if we declare
more than one variable with the same name and with different values, more than one
method with the same name and with the different implementations in more than one
super class and if we access that variable and method in the respective sub class then
which super class variable and which super class method will be executed is a confusion
state, but, JAVA is a simple programming language, it is not allowing multiple
inheritance in its programming.
In Python, Multiple Inheritance is allowed, because, Python is following a protocol
called as MRO[Method Resolution Order] , it has provided solution for the confusion of
Multiple Iheritance , as per MRO, if we access any super class member in the respective
sub class then PVM will search for the respective member in all the super classes as per
the order in which we specified in sub class declaration.
EX:
---
class A():
def m1():
---X-impl--
class B():
def m1():
--Y-impl---
class C(A,B):
---
c = C()
c.m1() # X-impl
class D(B,A):
-----
d = D()
d.m1() # Y-impl
9. Pointers are existed in C and C++ , but, Pointers are not existed in Java and Python:
----------------------------------------------------------------------------------
Pointer is a variable, it able to store address locations of the data structers, where data
structers may be a variable, an array, a struct, another pointer variable.
In general, pointers are recognized and initilized at the time of compilation.
Q)Why pointers are not existed in Java and Python?
-------------------------------------------------------
Ans:
----
1. Pointer variables required static memory allocation, but, JAVA and Python are
following dynamic memory allocation.
2. Pointer variables are supported by Static Programming Languages, but, Java and
Python are dynamic Programming Languages.
3. Pointers are very much suitable in Platform Dependent Programming languages,
but, Java and Python are platform Independent Programming Languages.
4. Pointer variables are able to provide less security for the data, but, JAVA and
Python are very good Secure programming languages, they must provide very good
security for the applications data.
5. Pointers is a bit confusion oriented feature, but, JAVA and Python are simple
programming lnaguages , they must not provide confusion to the developers.
Q)What are the differences between pointer variables, Reference variables and
Id variables?
---------------------------------------------------------------------------------
Ans:
----
1. Pointer variables are existed in C and C++.
Reference variables are existed in Java.
Id variables[Reference Variables] are existed in Python.
2. Pointer variables are able to refer a block of memory by storing its address location.
Reference variables are able to store a block of memory[Object] by storing Object
reference value, where Object reference value is an hexa decimal of Hashcode,
where hashcode is an unique identity for each and every object provided Heap
manager in the form of an integer value.
In Python, Id variables are able to refer a block of memory [Object] by storing
Object id value, where Object Id value is an unique identity provided by Memory
Manager in the form of an integer value.
3. Pointer variables required static memory allocations.
Reference variables and Id variables required dynamic memory allocation.
4. Pointer variables are recognized and initialized at compilation time.
Reference variables and Id variables are recognized and initialized at runtime.
10. C a C++ are following call by value and Call by Reference, but,
Java and Python are following Call By value only:
-----------------------------------------------------------------------------------
In any Programming Language, if we pass primitive data like byte, short, int, long,
float, double.... as parameters to the methods or functions then the parameter passing
mechanism is "Call by Value".
In any Programming Language, if we pass address locations as parameters to the
methods or functions then the parameter passing mechanism is "call By Reference".
In C and C++, if we pass pointer variables as parameters to the methods or functions
then the parameter passing mechanism is "Call By Reference", because, Pointer
variables are able to store address locations.
In Java and Python, if we pass Object reference value or Object Id value as parameters
to the methods or functions then the parameter passing mechanism is "Call by Value "
only, not "Call By Reference", because, in JAVA, Object reference value is not address
location and in Python Object Id value is not address location.
11. C and C++ are compilative Programming Languages, Python is an interpretive
programming language, but, JAVA is both Compilative and Interpretive
programming language :
----------------------------------------------------------------------------------
C and C++ are Compilative Programming languages, because, in C and C++ applications
majority of the operations like Memory allocations are going on at compilation time
only.
Python is an interpretive programming language, becasue, in Python applications every
operation is going on at runtime only, that is by using an interpreter.
Java is both Compilative and interpretive programming language, because, in Java
applications to check developers mistakes and to convert program from High level
representations to low level representations we need compilation and to execute java
programs we need an interpretor inside JVM.
12. Operator overloading is possible in C++ and Python, but, Operator Overloading is
not possibe in JAVA:
----------------------------------------------------------------------------------
The process of defining an operator with more than one operation or functionality is
called as Operator Overloading.
Operator Overloading is an implementation for Polymorphism.
The main advantage of Polymorphism is "Flexibility" to develop applications.
EX:
a = 10
b = 20
c = a + b // + is used for Arithmetic Addition
print(c)// OP: 30
str1 = "abc"
str2 = "def"
str3 = str1 + str2 // + is used for String concatination
print(str3)// OP: abcdef
In C++, operator overloading is possible by defining functions explicitly.
In JAVA, some of the predefined operators are declared as overloaded operators with
fixed functionalities, but, JAVA has not provided any option to perform operator
overloading explicitly at developers level.
In Python, we are able to get Operator overloading implicitly and explictly, we are able
to provide operator overloading by defining some magic functions.
13. Java is more portable than Python:
---------------------------------------
Java is more portable programming language, because, JAVA is able to provide very
good environment to prepare the applications like Standalone applications, Web
Applications, Diustributed applications, Mobile Based Applications,..... and JAVA
applications will take less execution time and performance of the Java applications is
more.
Python is less portable programming langiuage, because, it is not suitable in mobile
application development and its applications will take more execution time and
performance of Python applications is very less.
14. C , C++ and Java are following proper structer to prepare applications, but , Python
is not following proper structer to prepare applications:
----------------------------------------------------------------------------------
C is a Procedure Oriented Programming language, it has follow procedure orientation
style[Structer] to prepare application.
1. Macros
2. #define
3. #include
4. Global Variables
5. Structs
6. User defined Functions
7. Main Function
C++ and Java are Object Oriented Programming Languages, they will follow Object
Orientation style or Structer to prepare applications.
1. Comment Section
2. Package Section
3. Import Section
4. Classes/interfaces Section
5. Main Class Section.
Python is both Procedure Oriented and Object Oriented programming language,
it will not follow any structer to prepare applications, it includes both Procedure
oriented elements and Object Oriented elements in any direction.
----------------------------------------------------------------------------------
3. Python Features:
--------------------
To describe the nature of Python Programming Language we have to go for
Python Feature.
Python has provided the following features to describe its nature.
1. Simple and Easy To Learn
2. Freeware and Open Source
3. High level Programming Language
4. Platform Independent
5. Portable
6. Dynamically Typed
7. Both Procedure Oriented and Object Oriented
8. Interpreted
9. Multi Threaded
10.Extendable / Extensive
11.Embedded
12.Extensive Library
13.Multi Purpose Programming Language
14.Multi Tech Support
1. Simple and Easy To Learn:
------------------------------
Python is very simple and easy programming language to learn and to work, because,
1. Python Syntaxes and Statements are very simple, they are available like general
english statements.
2. Python has limited no of keywords/Reserved words[30 +] and they have limited
functionalities.
3. Less no of instructions are sufficient to prepare Python applications.
4. In Python applications, development time will be reduced, development cost will
be reduced and productivity will be increased.
2. Freeware and Open Source:
-----------------------------
Python is a Freeware, because, we are able to download and utilize python software
with out taking any licence.
Python is Open Source Software, because, Python source code is coming along with
Python software when we download, if source code available along with python
software then we are able to modify the existed python software and we are able to
utilize that python software as per our requirements.
3. High level Programming Language:
------------------------------------
Python is a high level programming language,because,
1. Python Syntaxes and Statements are very simple to understand and to use in
applications[Developers Friendly Programming Language].
2. Python is providing an abstraction layer for all the low level activities like
Memory Management, Security Management, H/W management,..... to the developers.
4. Platform Independent:
------------------------
Python is a platform independent programming language, because, Python
applications are executed in almost all the Operating Systems like windows, Linux,
Unix,... with out having changes in python applications.
Note: Python is platform independent programming language because of PVMs only,
but, PVM is platform dependent.
5. Portable:
-------------
Python is a portable programming language, because,
1. Python is able to allow its applications to execute under all the Operating
Systems and under all the H/W Systems.
2. Python programming language is very much suitable programming language for
some other products like Selenum, Hadoop,....
6. Dynamically Typed:
---------------------
Python is a dynamically Typed Programming Language,because, in Python applications
we will represent data with out specifying any particular data type, but, in python
applications, Python programming language will decide which type of data we
represented after providing data.
7. Both Procedure Oriented and Object Oriented:
------------------------------------------------
Python is both procedure oriented and Object Oriented Programming languages,
because, python is following procedure oriented features like functions, lambdas,
maps, reduces, filters,.... and Python is following Object Oriented Features like class,
object, encapsulation, abstraction, inheritance, polymorphism,....
8. Interpreted:
----------------
In Python, there is no seperate process for compilation, directly we will execute python
applications . IN general, Python programs are executed by PVM[Python Virtual
Machine], in PVM , an intepretor is responsible to execute python applications.
Note: In Python, PVM will take responsibility to check syntax errors by using "Syntax
Error Checkker".
9. Multi Threadded:
-------------------
Python is Multiple Threadded programming Language, because, Python is able to
provide very good environment to create and execute more than one thread at a time.
10.Extendable / Extensive:
---------------------------
Python is Extendable / Extensive programming language, because, it able to include
other programming languages functionalities in python applications as per the
requirement.
11.Embedded:
------------
Python is an embedded programming language, because, Python is able to allow to
embeed its functionalities in other programming language applications.
12.Extensive Library:
---------------------
Python is having very good predefined library to prepare diffderent types of
applications like PDBC applications, GUI Applications, Network applications,....
To prepare PDBC[Python Database Connectivity] applications Python jas provided
the complete library in the form of PDBC module.
To prepare GUI applications, Python has provided predefined library in the form
of seperate module called as "tkinter",.....
13.Multi Purpose Programming Language:
---------------------------------------
Python is Multi Purpose programming language, becauyse, Python is able to
provide very good envirtonment to prepare the following types of applications.
1. Standalone Applications.
2. Desktop / GUI applications
3. Database Related applications
4. Web applications
5. Distributed applications
6. Nueral Network based Applications
7. AI related applications
8. Data Science Related applications
-----
-----
14.Multi Tech Support:
-----------------------
Python is giving support to the multiple technologies like C, Java, .Net,......
EX:
---
1. Python is providing "Jython" as a flavour to run under Java environment.
2. Python is providing "Cython" as a flavour to run under C environment.
3. Python is providing "Iron Python" as a flavour to run under .Net environment
4. Python is providing "Anaconda Python" as a flavour to run under Data Science
environmemnt.
-----
-----
Steps to prepare Python Applications:
--------------------------------------
To prepare Python applications we have to use the following steps.
1. Download and Install Python Software
2. Write and Execute Python Applications
1. Download and Install Python Software:
----------------------------------------
1. Open "www.python.org" website in Browser.
2. Click on "Downloads".
3. Select "Windows x86-64 executable installer" link
4. Copy The downloaded Software and maintain that Software in our Softwares dump
5. Double Click on "python-3.7.4-amd64.exe" setup file.
6. Select "Install Laucher For all USers".[Bydefault Selected]
7. Select "Add Python 3.7 to PATH".
8. Click on "Customize Installation" Link.
9. Click on "Next" button.
10.Change Python installation location from
"C:\Users\Nagoor\AppData\Local\Programs\Python\Python37" to
"C:\Python\python37".
11. Click on "Install" button.
12. Click on "Yes" button.
13. Click on "Close" button.
2. Write and Execute Python Applications:
-----------------------------------------
To Write and Execute Python applications we will use the following ways.
a) By Using Python Provided IDLE[Integrated Development and Learning Environment]
b) By Using Python Shell in Command Prompt
c) By Using Editplus or Some Other Editors.
d) By Using PyCharm IDE
a) By Using Python Provided IDLE:
---------------------------------
a)Search for IDLE(Python3.7 64 bit) in System Search.
b)Select IDLE(Python3.7 64 bit)
c)Write Python program on IDLE and Execute Python Program
>>> print("Welcome to Python IDLE") --> Click on Enter Button
Welcome to Python IDLE
b) By Using Python Shell in Command Prompt:
--------------------------------------------
a)Open Command Prompt.
b)Use "python" command in Command Prompt.
c)Write Python program and Execute Python Program.
>>> print("Welcome To Python Shell in CMD") --> Click on Enter button
Welcome To Python Shell in CMD
c) By Using Editplus or Some Other Editors:
---------------------------------------------
To prepare and execute application by using Editplus, we have to use the following steps.
a)Download and Install Editplus:
1)Open "https://www.editplus.com/download.html" url in Browser.
2)Select " Download EditPlus Version 4 (64-bit)" Link.
3)Copy the downloaded "epp430_64bit" setup file from downloads and keep it in our Softwares dump.
4)Double Click on "epp430_64bit.exe" setup file.
5)Click on "Accept" button.
6)Click on "Yes" button.
7)Click on "Start Copy" Button.
8)Click on "OK" button.
b)Open Python File and Write Python Program in Editplus:
1)Double Click on "Editplus" on Desktop.
2)Click on b"Yes" button.
3)Click on "OK" button.
4)Provide Subscription code and Click on OK button.
5)Select "File"
6)Select "New"
7)Select "Others"
8)Select "Python"
9)Click on "OK" button.
10)Write Python Program
print("Welcome To Python-Editplus")
c)Save Python File :
a)Select "File"
b)Select "Save"
c)Provide FileName.py
d)Click on "Save" button.
d)Execute Python File
a)Open Command Prompt.
b)Goto the location Where Python files are saved.
c)Use either "python" command or "py" command on Command Prompt.
D:\python10>python welcome.py
Welcome To Python Editplus
D:\python10>py welcome.py
Welcome To Python Editplus
d) By Using PyCharm IDE
-------------------------
To prepare and execute applications by Using PyCharm IDE we have to use the following steps.
1. Download and Install PyCharm IDE
2. Open PyCharm IDE and Create Python Project
3. Create Python File and Write Python Program
4. Run Python Program
1. Download and Install PyCharm IDE:
-------------------------------------
1. Open "https://www.jetbrains.com/pycharm/download/" in Browser.
2. Click on "Download" under "Community".
3. Copy the downloaded PyCharm Software from Downloads to Our Softwares Dump
location.
4. Double Click on "pycharm-community-2019.2.exe" Setup File.
5. Click on "Yes" button.
6. Click on "Next" button.
7. Change PyCharm installation location from
"C:\Program Files\JetBrains\PyCharm Community Edition 2019.2" to
"C:\PyCharm\PyCharm Community Edition 2019.2"
8. Click on "Next" button.
9. Click on "Next" button.
10.Click on "Install" button.
11.Click on "Finish" button.
2. Open PyCharm IDE and Create Python Project:
----------------------------------------------
1. Seaarch and Select "Jetbrains PyCharm Community Edition" in our System Search.
2. Select "Light" Radio Button.
3. Select "Skip Remaining and Set Defaults" button.
4. Click on "Create New Project" Link.
5. Specify the Project Location[D:\Python10\PyCharm]
6. Click on "OK"
7. Click on "Create" button.
1. Select "File"
2. Select "New Project"
3. Provide Project Name [app01]
4. Click "Create" button.
5. Select "This Window".
6. Right Click on "app01" project.
7. Select "New"
8. Select "Python Package".
9. Provide Package Name [com.durgasoft]
10.Click on "OK" button.
3. Create Python File and Write Python Program:
-------------------------------------------------
1. Right Click on "durgasoft" package.
2. Select "New"
3. Select "Python File".
4. Provide file name [welcome.py]
5. Write Program in welcome.py file.
print("Welcome To PyCharm IDE")
4. Run Python Program
------------------------
When we run first time:
a)Right CLick on Editor
b)Select "Run Welcome".
From Second Time onwards:
Click on "Run" button.
3. Language Fundamentals:
--------------------------
To prepare Python applications, we need some constructs bydefault from Python
Programming language called as "Language Fundamentals".
To prepare Python applications, Python has provided the following fundamentals.
1. Tokens
2. Data Types
3. Type Casting
4. Python Statements
1. Tokens:
-----------
Lexeme: Logical Individual Unit in programming is called as Lexeme.
Token: The Collection of lexemes come under a particular group called as Token.
EX:
---
a = b + c * d
Lexemes: a, =, b, +, c, *, d ---> 7 Lexemes
Tokens:
Identifiers: a, b, c, d
Operators: =, +, *
Tokens: 2 types of tokens
To prepare Python applications, Python has provided the following tokens.
1. Identifiers
2. Literals
3. Keywords/Reserved Words
4. Operators
1. Identifiers:
----------------
Providing names to the programming elements like variables, functions, classes, ...
called as "Identifiers".
To provide identifiers in Python applications we have to follow a set of rules and
regulations.
1. All python identifiers must not be started with a number, they may start with an
alphabet or _ symbol, but, the subsequent symbols may be a number, an alphabet
or _ symbol.
EX:
---
eno = 111 ---> Valid
9eno = 9999 ---> Invalid
emp9Name = "Durga" ---> Valid
_ename = "Durga" ---> Valid
emp_Addr = "Hyd" --> Valid
$esal = 5000.0 ---> Invalid
2. All Python identifiers are not allowing all operators and all special symbols
except _ symbol.
EX:
---
empName = "Durga" ---> valid
emp.Name = "Durga" ---> Invalid
emp+Addr = "Hyd" ---> Invalid
emp-Sal = 5000.0 ---> Invalid
emp_Addr = "Hyd" ---> Valid
emp@Hyd = "Durga" ---> Invalid
3. All Python Identifiers are not allowing spaces in the middle.
EX:
---
empName = "Durga" ---> Valid
emp Name = "Durga" ---> Invalid
tempEmpAddr = "Hyd" ---> Valid
temp Emp Addr = "Hyd" ---> INvalid
4. In Python applications, we are unable to use keywords and reserved words
as identifiers.
EX:
if = 10 --> INvalid
for = 20 ---> Invalid
5. In Python applications, we are able to use all fundamental data types names and
sequence data types names as identifiers.
EX:
int = 10 --> Valid
float = 20 ---> Valid
bool = 50 ---> Valid
list = 100 --> Valid
set = 200 --> Valid
tuple = 70 --> Valid
list = [10, 20, 30, 40, 50] --> Valid
6. All Python identifiers are case sensitive.
EX:
---
ename = "Durga"
ENAME = "Ravi"
print(ename)
print(ENAME)
OP:
---
Durga
Ravi
Along with the above rules and regulations, Python has provided the following suggestions to provide identifiers.
1.In Python applications, it is suggestible to provide identifiers with a particular meaning.
EX:
xxx = "abc123" ----> Not Suggestible
accNo = "abc123" ----> Suggestible
2. In Python applications, there is no length restriction for the identifiers , we can prepare identifiers with any length but it is suggestible to manage length of the identifiers around 10 symbols.
EX:
temporaryemployeeaddress = "Hyd" ---> Not Suggestible
tempEmpAddr = "Hyd" ---> Suggestible
3. If we have multiple words in an identifiers then it is suggestible to seperate multiple words with the special notations like '_' symbols.
EX:
tempEmpAddr = "Hyd" ---> Not Suggestible
temp_Emp_Addr = "Hyd" --> Suggestible
Q)What is the difference between variable and identifier?
------------------------------------------------------------
Ans:
----
Variable is a memory location where data is stored, where name of the variable is called as an Identifier.
Note: In Programmnig Languages, when we access variable then we are able to get the data which was stored at the respective memory location, we are unable to get memory location directly.
2. Literals:
------------
Literal is a constant assigned to the variable
EX:
a = 10
a ---> variable/Identifier
= ---> Operator
10 --> Constant[Literal]
There are two types of literals in Python.
1. Numeric Literals
2. Non Numeric Literals
1. Numeric Literals:
---------------------
1. int literals : 10, 20, 30,....
2. float Literals : 123.234, 456.345,...
Note: Upto Python2.x version 'long' data type is existed and its literals are existed, but,
from Python3.x version long data type is not existed and its literals are not existed.
EX:
a = 10
print(a)
print(type(a))
OP:
10
<class 'int'>
EX:
a = 234.345
print(a)
print(type(a))
OP:
234.345
<class 'float'>
2. Non Numeric Literals:
------------------------
1. bool: True, False
2. str : if we provide any thing in ' '[Single quatotions], " "[Double quatotions],
''' '''[Triple Quatotions] then that literal is str literal.
Note: To represent string data in a single line then we are able to use '' or "" or ''' ''' , but,
to represent data in multiple lines then we are able to use ''' ''' only.
EX:
---
#b = true --> Error
b = True
print(b)
print(type(b))
c = False
print(c)
print(type(c))
OP:
True
<class 'bool'>
False
<class 'bool'>
EX:
---
s1 = 'Durga Software Solutions'
print(s1)
print(type(s1))
OP:
---
Durga Software Solutions
<class 'str'>
EX:
---
s2 = "Durga Software Solutions"
print(s2)
print(type(s2))
OP:
Durga Software Solutions
<class 'str'>
EX:
---
s3 = '''Durga Software Solutions'''
print(s3)
print(type(s3))
OP:
Durga Software Solutions
<class 'str'>
EX:
---
str = '''Durga
Software
Solutions'''
print(str)
print(type(str))
OP:
Durga
Software
Solutions
<class 'str'>
In String literals, it is not possible to provide single quatotions insise single quatotions
directly, but, it is possible with \, that is , \'.
EX:
---
str = 'Durga 'Software' Solutions'
Status: Syntax Error.
EX:
---
str = 'Durga \'Software\' Solutions'
print(str)
OP:
Durga 'Software' Solutions
In String literals, we are able to provide double quotations inside single quotation directly.
EX:
---
str = 'Durga "Software" Solutions'
print(str)
OP:
Durga "Software" Solutions
In String literals, it is not possible to provide triple quotations inside single quotation with or with /.
EX:
---
str = 'Durga '''Software''' Solutions'
Status: Syntax Error
EX:
---
str = 'Durga \'''Software\''' Solutions'
OP:
Durga 'Software' Solutions
In String literals, in side double quotations, we are able to provide single quotations and triple quotations directly ,but, we are unable to provide double quotations directly, but, we are able to provide doubles quotations with \.
EX:
---
str1 = "Durga 'Software' Solutions"
print(str1)
#str2 = "Durga "Software" Solutions" --> Error
str2 = "Durga \"Software\" Solutions"
print(str2)
str3 = "Durga '''Software''' Solutions"
print(str3)
OP:
---
Durga 'Software' Solutions
Durga "Software" Solutions
Durga '''Software''' Solutions
In String literals, inside triple quotations, we are able to provide single quotations and double quotations directly, we are unable to provide triple quotations directly , but, it is possible to provide triple quotations with \.
EX:
---
str1 = '''Durga 'Software' Solutions'''
print(str1)
str2 = '''Durga "Software" Solutions'''
print(str2)
#str3 = '''Durga '''Software''' Solutions''' --> Error
str3 = '''Durga \'''Software\''' Solutions'''
print(str3)
OP:
----
Durga 'Software' Solutions
Durga "Software" Solutions
Durga '''Software''' Solutions
Q)Find the right options to display the following string literal
'Durga' "Software" '''Solutions'''
1)str = '\'Durga\' "Software" \'''Solutions\''''
print(str)
2)str = "'Durga' \"Software\" '''Solutions'''"
print(str)
3)str = ''''Durga' "Software" \'''Solutions\''''''
print(str)
4)None
Ans: 2, 3
Q) eno = 111
ename = 'Durga'
esal = 50000.0
Find data types order of the variables ename,eno and esal respectovily?
1. str, float, int
2. str, int, float
3. float, str, int
4. None
Ans: 2
Number Systems:
----------------