Professional Documents
Culture Documents
Python Programming Fundamentals
Python Programming Fundamentals
1
Module 1: Introduction to Python and Computer Programming
Objectives of the Course
Learn Python from scratch
Learn how to setup a Python development environment
Learn how to create console applications
Learn about Python data types and casting
Python data structures
Python Modules and Packages
Python String methods and Formatting
Working with dates and time
Python Functions
Python Control Flow Statements
Working with external files in Python
Handling exception errors
Create desktop applications using Python
Programming Language
Programs are majorly referred to as software. Software is very important to a
computer because it controls everything the computer does. All of the software that
we use to make our computers useful is created by individuals working as
programmers or software developers. A programmer, or software developer, is a
person with the training and skills necessary to design, create, and test computer
programs. Computer programming is an exciting and rewarding career. Today, you
will find programmers’ work used in business, medicine, government, law
enforcement, agriculture, academics, entertainment, and many other fields.
A programming language is a formal language which comprises of a set of
instructions that produce various kinds of output. They are used in computer
programming to implement algorithms. They are set of rules which instructs the
computer to perform specific tasks. We have the high-level programming language
and the low-level programming language.
2
understand what the program is meant to do. Examples of high-level programming
languages include Python, Java, C#, C++, PHP, Ruby etc.
High-level Language
FORTRAN, C, Pascal
Hardware
3
Compilers and Interpreters
Because the CPU understands only machine language instructions,
programs that are written in a high-level language must be translated into machine
language. Depending on the language that a program has been written in, the
programmer will use either a compiler or an interpreter to make the translation. A
compiler is a program that translates a high-level language program into a separate
machine language program. The machine language program can then be executed
any time it is needed.
A compiler is used to translate the entire source code into machine language
before the code is executed. For the computer to understand what you are trying to
do, you need the compiler to translate the code to what the machine can read and
understand. Examples of languages that are compiled before the code is executed
includes C and C++.
Interpreter performs a similar job like the compiler. The difference between
the compiler and the interpreter is that the interpreter translates or convert one
line of code at a time into machine language before the code is executed. Examples
of languages that uses an interpreter is the Python and Perl.
a=4 00001010
b=8 11000111
Compiler CPU 12
sum = a + b 10110011
Print(sum) 00101010 Result
4
2 Generate machine code Does not generate machine code
3 Uses more memory Less memory is used
4 Compiles once and runs anytime Source code is interpreted each time
5 More difficult to debug Easy to debug
6 Faster Slower
What is Python?
Python is a widely-used, interpreted, object-oriented, and high-level
programming language with dynamic semantics, used for general-purpose
programming. And while you may know the python as a large snake, the name of
the Python programming language comes from an old BBC television comedy
sketch series called Monty Python's Flying Circus.
At the height of its success, the Monty Python team were performing their
sketches to live audiences across the world, including at the Hollywood Bowl. Since
Monty Python is considered one of the two fundamental nutrients to a programmer
(the other being pizza), Python's creator named the language in honor of the TV
show.
5
Module 2: Command Line Interface, Python Installation and Setup
PyCharm Basic Configuration Setup on Windows
When you launch PyCharm for the first time, you get a screen shown in
figure 2.1. that ask you to import PyCharm settings. This usually happens if you
got PyCharm installed previously and you are installing maybe a different version
and you got some settings saved. Then check “Do not import settings” and click OK
to progress to the next screen.
6
Figure 2.3: Data Sharing Interface
Once it launches, you have the figure 2.4. Now, configure the basic
configurations.
7
Figure 2.5: Settings Interface
From the figure 2.6, there is no interpreter selected. To add an interpreter,
go to the settings sign beside the drop-down button and click on Add. Click on
“System Interpreter” as shown in figure 2.7 and click OK, then the package list will
be loaded. Click on OK button to update the Python interpreter. Once the
interpreter has been updated, you are back to the welcome screen.
8
Figure 2.6: Settings interface to add Python Interpreter
9
Figure 2.9: Adding an Interpreter to a New Python Project
10