المستند 103
المستند 103
.Known for its simple syntax, making it easy to learn and read -
**:Print statement** -
python```
```
**:Comments** -
:Multi-line comment -
python```
"""
This is a
Multi-line comment
"""
```
python```
Name = "Alice" # String
Age = 25 # Integer
```
python```
Print(fruits[0]) # apple
```
.Tuple:** Ordered, immutable collection ** -
python```
```
.Dictionary:** Key-value pairs** -
python```
Print(person["name"]) # Bob
```
.Set:** Unordered collection of unique elements ** -
python```
```
**:Conditional Statements** -
python```
:If age > 18
Print("Adult")
:Elif age == 18
:Else
Print("Minor")
```
**:Loops** -
:For loop -
python```
Print(fruit)
```
:While loop -
python```
Count = 0
Print(count)
Count += 1
```
python```
:Def greet(name)
:Reading a file -
python```
)(Content = file.read
```
:Writing to a file -
python```
File.write("Hello, World!")
```
python```
:Try
Result = 10 / 0
:Except ZeroDivisionError
```