š¦ Variables š Type Casting š Strings
Create these variables for your Roblox character:
name = your username (string)level = 5 (integer)health = 100.0 (float)coins = 250 (integer)Then:
Example Output:
CoolGamer
5
100.0
250
CoolGamer is level 5 with 84.5 HP and 300 coins
ā Operators
Calculate and print the answers:
# 1. Complete 3 quests worth 50 XP each total_xp = # 2. Start with 150 health, take 35 damage health_left = # 3. Split 500 coins among 4 players (whole number) coins_each = # 4. You have 25 gems. Need 7 for each craft. How many left over? leftover = # 5. Can you enter? (Need level 10+, you're level 12) can_enter =
Example Output:
150
115
125
4
True
š„ Input š Strings š Type Casting
Ask the user:
Then print:
Example Output:
Enter username: DragonKing
Enter age: 13
10
D
Welcome DragonKing! You are 13 years old.
š Conditionals š Indentation
Part A:
level = 15 has_pass = True
If level >= 10 AND has_pass, print "VIP Access!". Otherwise print "Access Denied"
Part B:
score = 85
Print rank based on score:
Part C:
coins = 120 item_cost = 100 in_shop = True
If in_shop is True:
Example Output:
VIP Access!
B Rank
Bought! 20 coins left
š Lists š For Loops
Start with: inventory = ["sword", "potion", "shield"]
Do this in order:
Example Output:
['sword', 'potion', 'shield']
['gem', 'sword', 'shield', 'helmet']
4 items
First: gem
Last: helmet
1. gem
2. sword
3. shield
4. helmet
Part A: Start with 0 coins. Use a while loop to add 20 coins at a time until you have 100+. Print coins each time.
Part B: Start with 0 coins. Loop forever asking "Collect or stop?". If "collect", add 25 coins. If "stop", break. Print total at the end.
Example Output:
=== Part A ===
20
40
60
80
100
Done! 100 coins
=== Part B ===
Collect or stop? collect
25 coins
Collect or stop? collect
50 coins
Collect or stop? stop
Final: 50 coins
Part A:
players = ["Steve", "Alex", "Notch", "Jeb", "Dinnerbone"]
Use a for loop to print the first 3 players with medals (š„ š„ š„)
Part B:
scores = [100, 150, 200, 250, 300]
Use a for loop to print each score. Then print the total.
Part C: Make a countdown from 5 to 1, then print "GO!"
Example Output:
=== Top 3 ===
š„ Steve
š„ Alex
š„ Notch
=== Scores ===
100
150
200
250
300
Total: 1000
=== Countdown ===
5
4
3
2
1
GO!
Part A: Make a function show_health(name, hp) that prints "[name] has [hp] HP". Call it 3 times.
Part B: Make a function calc_damage(base, multiplier) that returns base Ć multiplier. Call it and print the result.
Part C:
player_hp = 100 damage = calc_damage(15, 2) # Calculate damage player_hp = player_hp - damage # Subtract it show_health("Hero", player_hp) # Show new health
Example Output:
=== Part A ===
Steve has 100 HP
Alex has 75 HP
Creeper has 20 HP
=== Part B ===
Damage: 30
=== Part C ===
Hero has 70 HP
Make a battle between Player (100 HP) and Goblin (60 HP).
Use a while loop:
Print who wins!
Example Output:
Player: 100 HP | Goblin: 60 HP
Attack? (yes/no): yes
Player: 90 HP | Goblin: 40 HP
Attack? (yes/no): yes
Player: 80 HP | Goblin: 20 HP
Attack? (yes/no): yes
Player: 70 HP | Goblin: 0 HP
You win!