This document provides an overview of basic Python programming concepts including programming languages, compilers, interpreters, linkers, loaders, Python syntax checking, Python virtual machine, commenting in Python, Python character sets, tokens, literals, variables, keywords, operators, delimiters, and the print function. It explains key elements like machine language uses 0s and 1s, high level languages are easier for humans, compilers translate to machine code while interpreters convert line by line, and linkers combine program modules into a single executable.
2. Overview of Programming
Languages
• Machine Language: Bianary form i.e
using only 0s and 1s.
• Assembly Language: Machine operations
are represented by mnemonic code(such as ADD &
MOV)
• High Level Language: Much easier to
write than low level language because program
instruction similar like English language.
4. Compiler
• It is a software
• Translate high level language code
into machine language code(0s and
1s)
• The compiled program is called
object code.
• It is a executable code does not need
the compiler during execution.
5. Interpreter
• Compiler converts all source code
into machine code.
• Where the interpreter reads the
source code line by line and converts
it into object code.
6. Linker
• Linking the different program
modules and libraries to form a
single executable program.
8. Internal working of python
Syntax checker and Translator
Python Virtual Machine(PVM)
Python code
Byte code
Input
9. STEPS
• STEP1: Python interpreter reads a
python code and verify it for syntax
error. If it found any error, immediately
halts the translation and shows an error
message.
• STEP2: If there is no error; interpreter
translate a code into byte code
• STEP3: Byte code is sent to the PVM.
Here again the byte code is executed on
PVM. If error found then the PVM halts
and show the error message.
10. Commenting in Python
• Python single line comment preceded
by a hash symbol (#)
• Three consecutive single quotation
marks ‘’’ are used to give multiple
comments (or) paragraph comments.
11. Example
• # Now learn how to comment in
Pyhon
• Print (“I am learning Python”)
• ‘’’Python tool
• Is easy to
• Learn’’’
• Print(‘bye’)
12. Python character set
• Letters: upper case and lower case
• Digits: 0,1…9
• Special symblos: _,{}[]()#*&^’”:;
• White space(tnx0bx0cr) space,
tab
14. 1. Literal
• Literals are numbers or strings or characters
appear in the program.
• Example:
• 78 – Integer literal
• 21.32- floating point literal
• ‘q’- character literal
• “Hello” – String literal
• (Python also contain list and dictionary)-see
later chapter
15. 2. Value and Type
• To know type of any value in Python
use in-build method called
type(value)
• Example:
• >>>type(‘hello’)
• >>>type(“hello”)
• >>>type(123)
16. Keywords
• Keywords are fixed
meaning/reserved words.
• Cannot be used as
identifiers/variables.
• Sample keywords: from, none, with,
while, true, return, is , in, import, if ,
gloabl, for, finally, else….
17. Operator
• Python contains various operators
• Arithmetic - + - * / % **
• Relational == != <> <= >=
• Logical and not or
• Bitwise &~|^<< >>
18. Delimiter
• It is symbol that perform special role
in python like grouping, punctuation
and assignment
• () [] {}
• , :. = ;
19. Variable
• Identifier is the name used to find variable,
function, class or other objects
• Rules:
• Character consists of letter, underscore,
digits,
• Can be any length
• Starts with letter
• Can start with _
• Cannot starts with a digit
• Cannot be a keyword
21. The Print() Function
• The task of print function is to
display the contents on the screen
• Print(argument)
• >>>print(‘Hello welcome to python
programming’)
• Print(1000)