Python Fundamentals
By,
Athira V
Terminology
➢ Program : A program is a sequence of instructions that specify how to perform a
computation.
➢ Programming language: The language using which a program is done is known as
programming language.
Eg: C. C++, Java, Python etc.
➢ Programmer : The people who does programming are known as programmers.
What is Python?
➢ Python is Free and Open Source
• Free means something that can be downloaded without paying anything.
• Something whose source code is available. So that we can do modification or
improve it.
➢ Object-Oriented Programming Language
➢ Python is a case sensitive language
➢ Python is used for web development, Software development, Scientific
applications.
Character set
➢ It is a collection of valid characters that a language can recognise. we can either enter through
keyboard as input or display as output on monitor.
➢ They can be present in the form of
• Letters A-Z, a-z
• Digits 0-9
• Special symbols #,@,& etc
• Whitespaces Space created using spacebar key, Enter key, Tab key
Modes in Python
➢ Interactive Mode
• This mode is used in Python to get immediate results of our code.
• This mode is useful in cases like learning, experimenting, testing etc.
• Interactive mode is denoted by the symbol >>>
• The only drawback of interactive mode is that we cannot save the statements for
further use.
• We have to retype the statements to re-run them.
Modes in Python
➢ Script Mode
• This mode is used to save all the commands in the form of program files and see the
output lines together rather than sandwiched between successive commands.
Tokens
➢ Tokens are the smallest unit of the programming language
➢ All/ anything that we use in our program is a part of Token
➢ It consist of 5 main elements
Keywords
➢ These are the reserved words whose meaning is already defined in
the language.
➢ They serve a specific task/ purpose for which they are created.
➢ They can not be used for any other purposes.
➢ Exampled of some keywords are
• if
• else
• for
Identifiers
➢ These are the unique names that we provide to different programming
elements (such as variables, functions, class etc) which are created by us.
➢ Naming rules of identifiers:
• The name should not start with digits.
• It should not be a keyword.
• It should not contain any special symbols in it (only special symbol
allowed is _ (underscore).
• The names are case sensitive
• It should not have a blank space in it.
• The name can be the combination of A-Z, a-z, 0-9 and _(underscore)
Literal/ Values
➢ These are the constant (fixed) values that do not change during the
program execution.
➢ It is the value that we assign to the variable. Eg a=10
➢ Example of String Literals in Python name = ‘Johni’ , fname =“johny”
➢ Example of Integer Literals in Python(numeric literal) age = 22
➢ Example of Float Literals in Python(numeric literal) height = 6.2
➢ Example of Special Literals in Python name = None
Operators
➢ It may be defined as the tokens that trigger some computation when
applied to variables and other objects in an expression.
➢ The variables to which the computation is applied are called operands.
Operator
>>> x=2+3
Operands
Punctuators
➢ It may be defined as symbols that are used in programming languages to organise sentence
structures.
Eg : ‘ “ # \ ( ) [] {} @ , . : ;
Input and Output
➢ We use print() function to output data to the standard output device (screen).
print(‘Computer Science’)
output:
Computer Science
➢ To take input from the user we use input(prompt)
prompt is a String, representing a default message before the input.
a) print('Enter your name:’) b) x = input('Enter your name:’)
x = input() print('Hello, ' + x)
print('Hello, ' + x)
THANK YOU