# Python Tutorials
## Basics
### Variables and Data Types
Variables store information in Python, and their types can change dynamically.
```python
# Example
x = 10 # Integer
x = "Now I'm a string!" # String
# Different data types
integer = 5
floating_point = 3.14
boolean = True
string = "Hello, World!"
print(f"Integer: {integer}, Float: {floating_point}, Boolean: {boolean}, String:
{string}")
```
### Lists and Dictionaries
```python
# Example: Lists
fruits = ["Apple", "Banana", "Cherry"]
for fruit in fruits:
print(fruit)
# Example: Dictionaries
person = {"name": "Ali", "age": 25, "city": "Karachi"}
print(f"{person['name']} lives in {person['city']}.")
```
### Advanced Conditionals
```python
# Example
number = 10
if number % 2 == 0:
print(f"{number} is even.")
else:
print(f"{number} is odd.")
```
## Advanced Loops and Iterations
```python
# Nested Loops Example
for i in range(3):
for j in range(2):
print(f"i={i}, j={j}")
```
### Functions with Keyword Arguments
```python
# Example
def introduce(name, age=18):
print(f"My name is {name} and I am {age} years old.")
introduce("Ali", 25)
introduce("Sara")
```
## Intermediate
### File Handling with JSON
```python
# Example
import json
data = {"name": "Ali", "age": 25}
with open("[Link]", "w") as json_file:
[Link](data, json_file)
with open("[Link]", "r") as json_file:
loaded_data = [Link](json_file)
print(loaded_data)
```
### Classes with Inheritance
```python
# Example
class Vehicle:
def __init__(self, brand, model):
[Link] = brand
[Link] = model
def info(self):
print(f"Vehicle: {[Link]} {[Link]}")
class Car(Vehicle):
def start_engine(self):
print("Engine started!")
car = Car("Tesla", "Model S")
[Link]()
car.start_engine()
```
### Decorators
```python
# Example
def greet_decorator(func):
def wrapper(name):
print("Hello!")
func(name)
print("Goodbye!")
return wrapper
@greet_decorator
def greet(name):
print(f"How are you, {name}?")
greet("Ali")
```
---
# Roblox Lua Tutorials
## Advanced Topics
### Tables and Metatables
```lua
-- Example: Tables as arrays and dictionaries
local fruits = {"Apple", "Banana", "Cherry"}
for i, fruit in ipairs(fruits) do
print(i, fruit)
end
-- Metatable example
local t = {a = 1}
local mt = {
__index = function(table, key)
return key .. " not found!"
end
}
setmetatable(t, mt)
print(t.b) -- Output: b not found!
```
### Advanced Events
```lua
-- Example: Connecting multiple events
local part = [Link]
[Link]:Connect(function(hit)
if [Link]:FindFirstChild("Humanoid") then
print([Link] .. " touched the part!")
end
end)
```
### Working with Cameras
```lua
-- Example
local camera = [Link]
[Link] = [Link]
[Link] = [Link]([Link](0, 10, 0))
```
### Animating GUI Elements
```lua
-- Example
local frame = [Link]
for i = 1, 100 do
[Link] = [Link](0, i, 0, 0)
wait(0.05)
end
```
### Game Monetization: Developer Products
```lua
-- Example
local MarketplaceService = game:GetService("MarketplaceService")
local productId = 123456
[Link]:Connect(function(player, id,
wasPurchased)
if id == productId and wasPurchased then
print([Link] .. " purchased the product!")
end
end)
```