Python Notes 1
Python Notes 1
Maya Nair
What is a Software ?
• Computer is a bare machine,
• We need to give instructions that tell a computer what to do
• A software is a set of such instructions
Machine language
program
(executable file)
Input Data Data entered CPU
during execution
Computed results
Program Output
Programming with Python I Maya Nair 27-10-2021 11
Compilation
Source Target
Program Compiler Program
Input
Output
Candidate's name is Andrews and age is 32
e.g:
if marks > 80 :
grade=‘A’
else :
grade=‘B’
Programming with Python I Maya Nair 27-10-2021 26
if.. elif… Statement
Syntax
if expression:
Python Statement
Statements elif expression:
Conditional
Statement
Statement
:
.
else :
Statement
Output
3 letters found
Programming with Python I Maya Nair 27-10-2021 37
String Slicing
• There are many inbuilt operators and functions for manipulating strings
• String indexing operator [ ] and string slicing [:] are two main operators
• String slicing gives a substring of one or more charcters from the string as per, start index,stop index
and step value provided by user
S = 'ABCDEFGHI’
print(S[2:7]) # CDEFG
Output
1
ABC
2.3
>>> print(Stud_dict.get("Marks"))
[85, 55, 40, 60, 90]