Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
7 views

Arithmetic Operators in Python

The document discusses arithmetic operators, input/output functions, data types, and a comparison of Scratch and Python programming languages. It covers basic arithmetic operators like addition and subtraction in Python. It also discusses how to take user input and display output using functions like input() and print(). It describes different data types in Python like integers, floats, and strings. Finally, it compares block-based Scratch to text-based Python, noting Python is more complex but offers unlimited potential.

Uploaded by

panagiotisp14
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Arithmetic Operators in Python

The document discusses arithmetic operators, input/output functions, data types, and a comparison of Scratch and Python programming languages. It covers basic arithmetic operators like addition and subtraction in Python. It also discusses how to take user input and display output using functions like input() and print(). It describes different data types in Python like integers, floats, and strings. Finally, it compares block-based Scratch to text-based Python, noting Python is more complex but offers unlimited potential.

Uploaded by

panagiotisp14
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

Arithmetic Operators in Python:


o Python supports various arithmetic operators for mathematical operations:
 Addition (+): Adds two numbers.
 Subtraction (-): Subtracts one number from another.
 Multiplication (*): Multiplies two numbers.
 Division (/): Divides one number by another.

2. Input and Output in Python:


o To take input from users, you can use the input() function. It reads a line
from the keyboard and returns it as a string.
 Example:

Python

name = input("Enter your name: ")


print("Hello, " + name)

o To display output, use the print() function. You can format the output using
placeholders or f-strings.
 Example:

Python

x = 5
print("The value of x is", x)

3. Data Types in Python:


o Python has several built-in data types:
 Numeric Types: int, float, complex
 Text Type: str
 Binary Types: bytes, bytearray, memoryview
 None Type: NoneType
o You can check the data type of any object using the type() function.
 Example:

Python

x = 20
print(type(x)) # Output: <class 'int'>

4. Scratch vs. Python:


o Scratch:
 Block-based programming language suitable for younger students.
 Great for creating art, games, and simple projects.
 Enriched with hardware integration.
 Takes up a lot of screen space for less programm
o Python:
 Text-based programming language suitable for secondary students.
 More complex but offers unlimited project potential.
 Widely used at higher levels of education and in professional
settings.
 Takes less screen space for more program which means that you can
make more complex programs

 Green = a string
 Grey= a comment
 Orange = a number or a parameter (or a predefined property
name(for instance .length ))
 Purple = special keyword (like var , if , else , etc)
 Light-blue = operator ( + , - , * , / , = , < , == , && , etc)
 Dark-blue = a predefined function name or the function name
in a function ...

You might also like