Class 10 - Basic Coding in Python
Class 10 - Basic Coding in Python
[email protected]
Python
1.Hello World
2.Strings
Python REPL
3.Functions
Read
4.Booleans Evaluate
Print
5.Loops Loop: get ready for the next input
Python: Data Types •stringwith
•string = anything = anything
" aroundwith
it is "aaround
string it is a string
1. strings = some text with no numerical value. e.g. "Hello World“: > anything with a “ sign is a string
2. int = A whole number. e.g. 3: > any integer number without “ sign
3 float = A decimal value e.g. 3.1415: > any decimal number without “ sign
4. bool = A Boolean value e.g. True or False: > Classifications without “ sign
Lexicon:
Int – integer
Bool – George Boole
Python: Data Types
• Because of the quotes, Python understands this is a sequence of characters and not a command,
number, or variable
• Can use single or double quotes (but not 2 single quotes) around each letter
• English wording like ‘It’s‘ (it is) will cause syntax error sue to multiple single quotes in a string
Hit
RUN
Concatenation :
Be mindful of the space (after hitting Space key) between asterisks and strings
Hit
RUN
Concatenation
• Concatenations (using +) a string with any other data type will give an error
• Turn the other data type into a string using [str] command (from string)
Hit
RUN
• Uppercase letters are ‘smaller’ than lowercase letters, eg: ‘M’ < ‘m’
• Digits are smaller than letters: ‘1’ < ‘a’