Class 11 - Basic Coding in Python - 2
Class 11 - Basic Coding in Python - 2
[email protected]
Python
1. Uses compilers (translators) to input your code into machine code 1. Directly writes source code
2. Are faster 2. Are slower (each command is executed sequentially)
3. C, C++, Pascal 3. Python, MATLAB
Eg. Print(Welcome)
Python REPL
Read
Evaluate
Print
Loop: get ready for the next input
Python in Replit
1. Hello World
3.Booleans
5. Loops
Variables
Rule Examples
Python has keyword/reserved words that you cannot use as False, class, finally, is, return, None, continue for, try, True, def,
variable names: from, while, and, not, with, as, elif, if, or, yield, assert, else,
import, except etc
Remember that strings were enclosed by single/double quotation marks: ”class” or “exam” etc
Variables
Remember that strings were enclosed by single/double quotation marks: ”class” or “exam” etc
Resources scarce: delay in Console when hitting Run
Variables: overwriting other variables
Hit
RUN
Assign a multiline string to a variable by using three double quotes OR three single quotes
Finding string length with len() function
You can Copy-paste the Latin text from the above command line
Slicing (cutting) strings
1. Slice in between
1. Specify the start index and the end index, separated by a colon (:), to return a part of the string
2. Leave out the start index, so that the range will start at the first character:
Hit twice
Note the indentation
ENTER
Next week we meet here