0% found this document useful (0 votes)
13 views

Class 10 - Basic Coding in Python

Basic coding in Python can be summarized as follows: 1. Python is an interpreted language that directly executes instructions without needing compilation. It is also extensible to other languages like C and uses natural language elements, making it high-level. 2. Python code can be organized into modules to reuse across programs. Programs are also typically shorter to write in Python compared to languages like C or Java. 3. Python supports basic data types like strings, integers, floats, and booleans. Strings use quotation marks while other types do not. Concatenation can join strings using the + operator.

Uploaded by

Naimur Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Class 10 - Basic Coding in Python

Basic coding in Python can be summarized as follows: 1. Python is an interpreted language that directly executes instructions without needing compilation. It is also extensible to other languages like C and uses natural language elements, making it high-level. 2. Python code can be organized into modules to reuse across programs. Programs are also typically shorter to write in Python compared to languages like C or Java. 3. Python supports basic data types like strings, integers, floats, and booleans. Strings use quotation marks while other types do not. Concatenation can join strings using the + operator.

Uploaded by

Naimur Rahman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Basic coding in Python

[email protected]
Python

• an interpreted language (no compilation is necessary, directly executes instructions)

• is extensible to other languages (eg C)

• is a high-level language (eg. more intuitive, uses natural language elements)

• can be split into modules to reuse in other Python programes

• is (much) shorter to write than eg. C or Java


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

1. strings = some text with no numerical value. e.g. "Hello World"


2. int = A whole number. e.g. 3
3 float = A decimal value e.g. 3.1415
4. bool = A Boolean value e.g. True or False
Strings

• A string in Python is a sequence of characters (text)

• A Python string needs quotes around it for it to be recognized: 'Hello, World‘

• 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

• To get around, use backward slash: 'It↘’s’


Python : Hello, world / Input = name
Concatenation

1. Concatenation = to add strings


2. Place a + between strings

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

Insert your age


Boolean operators and conditional operators

Operator Meaning Hit


> greater than RUN
< smaller than
>= greater than or equal to

<= smaller than or equal to


== is equal
!= is not equal

Also work with strings of letters:

• Uppercase letters are ‘smaller’ than lowercase letters, eg: ‘M’ < ‘m’
• Digits are smaller than letters: ‘1’ < ‘a’

You might also like