Basic Commands - Bryantad/Sona GitHub Wiki

📝 Basic Commands - Your Essential Sona Toolkit

Welcome to Your Programming Toolkit! 🛠️

This guide covers the essential Sona commands that you'll use every day. Perfect for beginners aged 12-55+ who want to master the fundamentals and build a solid foundation in programming.


🎯 What You'll Learn

By the end of this guide, you'll be able to:

  • ✅ Use all the basic Sona commands confidently
  • ✅ Understand when to use each command
  • ✅ Build simple programs using these commands
  • ✅ Debug common command-related errors
  • ✅ Create useful programs for daily life

🌟 The Essential Commands

1. show - Display Information

The show command displays text, numbers, or variables on the screen.

show "Hello, World!"
show 42
show "The answer is " + 42

name = "Alex"
show "Hello, " + name

What it does:

  • Displays text in quotes
  • Shows numbers directly
  • Combines text and numbers with +
  • Works with variables

Common uses:

  • Greeting users
  • Displaying results
  • Showing program output
  • Debugging (seeing what's in variables)

2. calculate - Do Math

The calculate command performs mathematical operations.

calculate 5 + 3
calculate 10 - 4
calculate 6 * 7
calculate 20 / 4
calculate 2 ^ 3  # 2 to the power of 3

Math operations:

  • + addition
  • - subtraction
  • * multiplication
  • / division
  • ^ exponentiation (power)
  • % remainder (modulo)

With variables:

price = 10
quantity = 3
total = price * quantity
calculate total

3. when - Make Decisions

The when command makes your program smart by making decisions.

age = 16
when age >= 18:
    show "You can vote!"
else:
    show "You can't vote yet"

Comparison operators:

  • == equal to
  • != not equal to
  • > greater than
  • < less than
  • >= greater than or equal to
  • <= less than or equal to

Multiple conditions:

temperature = 75
when temperature > 80:
    show "It's hot!"
when temperature > 60:
    show "It's warm"
else:
    show "It's cold"

4. repeat - Do Things Multiple Times

The repeat command automates repetitive tasks.

# Repeat a specific number of times
repeat 5 times:
    show "Programming is fun!"

# Repeat with a list
fruits = ["apple", "banana", "orange"]
repeat for each fruit in fruits:
    show "I like " + fruit

Counting loops:

repeat for i from 1 to 10:
    show "Count: " + i

5. think - Add Notes

The think command lets you add notes to your code.

think "This program calculates the area of a rectangle"
length = 10
width = 5
area = length * width
think "Area formula: length × width"
show "Area: " + area

Why use thinking blocks:

  • Document your code
  • Remember what you were thinking
  • Help others understand your program
  • Organize your thoughts

6. Variables - Store Information

Variables store information for later use.

# Text (strings)
name = "Sam"
message = "Hello, World!"

# Numbers
age = 25
temperature = 72.5

# True/False (booleans)
is_student = true
is_raining = false

# Lists
colors = ["red", "blue", "green"]
numbers = [1, 2, 3, 4, 5]

🎯 Putting It All Together

Example 1: Grade Calculator

think "Creating a grade calculator"
show "=== Grade Calculator ==="

# Input grades
math_grade = 85
science_grade = 92
english_grade = 88

# Calculate average
calculate average = (math_grade + science_grade + english_grade) / 3

show "Math: " + math_grade
show "Science: " + science_grade  
show "English: " + english_grade
show "Average: " + average

# Determine letter grade
when average >= 90:
    show "Letter Grade: A"
when average >= 80:
    show "Letter Grade: B"
when average >= 70:
    show "Letter Grade: C"
else:
    show "Letter Grade: F"

Example 2: Shopping List Manager

think "Managing a shopping list"
show "=== Shopping List ==="

# Create shopping list
shopping_list = ["milk", "bread", "eggs", "apples"]

# Show each item
show "Items to buy:"
repeat for each item in shopping_list:
    show "- " + item

# Calculate total items
total_items = shopping_list.length
show "Total items: " + total_items

# Check if we need milk
when "milk" in shopping_list:
    show "Don't forget the milk!"

Example 3: Weather Advisor

think "Weather advice program"
show "=== Weather Advisor ==="

temperature = 68
is_raining = false
wind_speed = 5

# Temperature advice
when temperature > 80:
    show "It's hot! Wear light clothes."
when temperature > 60:
    show "It's nice! Perfect for a walk."
else:
    show "It's cold! Wear a jacket."

# Rain advice
when is_raining:
    show "Don't forget your umbrella!"
else:
    show "No rain expected!"

# Wind advice
when wind_speed > 15:
    show "It's windy! Hold onto your hat!"

🎨 Accessibility Features in Commands

🧠 For Neurodivergent Users

Consistent patterns:

# All commands follow the same pattern
show "information"
calculate 5 + 3
when condition: action
repeat 3 times: action
think "note"

Predictable behavior:

# Commands always do the same thing
show "Hello"    # Always displays text
calculate 2 + 2 # Always does math
when true: show "Yes"  # Always checks conditions

👁️ For Visual Accessibility

Clear syntax highlighting:

# Commands are highlighted differently from data
show "This is a command"
name = "This is data"
when age > 18: show "This is a condition"

Readable structure:

# Indentation shows relationships
when weather == "sunny":
    show "Wear sunglasses"
    show "Use sunscreen"

🎧 For Audio Accessibility

Screen reader friendly:

# Commands are announced clearly
show "Screen reader will say: 'show command'"
calculate 5 + 3  # "calculate command, 5 plus 3"

🔧 Command Combinations

Variables with Commands

# Store command results
name = "Alex"
age = 16
result = 5 + 3

# Use variables in commands
show "Hello, " + name
when age >= 16: show "You can drive!"
calculate result * 2

Nested Commands

# Commands inside other commands
when (5 + 3) > 7:
    show "Math works!"

repeat 3 times:
    when true:
        show "This runs 3 times"

Complex Expressions

# Multiple operations in one command
calculate (10 + 5) * 2 - 3
show "Result: " + ((10 + 5) * 2 - 3)

🆘 Common Mistakes and How to Fix Them

Mistake 1: Forgetting Quotes

# Wrong
show Hello World

# Right
show "Hello World"

Mistake 2: Wrong Math Operator

# Wrong
calculate 5 x 3

# Right
calculate 5 * 3

Mistake 3: Missing Colon in When

# Wrong
when age >= 18
    show "Adult"

# Right
when age >= 18:
    show "Adult"

Mistake 4: Incorrect Indentation

# Wrong
when age >= 18:
show "Adult"

# Right
when age >= 18:
    show "Adult"

🚀 Practice Exercises

Exercise 1: Personal Information

Create a program that shows information about yourself:

think "Program about me"
# Fill in your information
name = "Your Name"
age = 16
city = "Your City"
favorite_food = "Your Favorite Food"

show "About Me:"
show "Name: " + name
show "Age: " + age
show "City: " + city
show "Favorite Food: " + favorite_food

Exercise 2: Simple Calculator

Build a calculator that does multiple operations:

think "Multi-operation calculator"
number1 = 10
number2 = 3

show "Calculator Results:"
show number1 + " + " + number2 + " = " + (number1 + number2)
show number1 + " - " + number2 + " = " + (number1 - number2)
show number1 + " * " + number2 + " = " + (number1 * number2)
show number1 + " / " + number2 + " = " + (number1 / number2)

Exercise 3: Age Categories

Write a program that categorizes people by age:

think "Age categorization program"
age = 25

show "Age: " + age
when age < 13:
    show "Category: Child"
when age < 20:
    show "Category: Teenager"
when age < 60:
    show "Category: Adult"
else:
    show "Category: Senior"

Exercise 4: List Manager

Create a program that works with lists:

think "List management program"
hobbies = ["reading", "swimming", "coding", "gaming"]

show "My Hobbies:"
repeat for each hobby in hobbies:
    show "- " + hobby

show "Total hobbies: " + hobbies.length
show "First hobby: " + hobbies[0]
show "Last hobby: " + hobbies[hobbies.length - 1]

🎯 Quick Reference

Essential Commands

Command Purpose Example
show Display information show "Hello!"
calculate Do math calculate 5 + 3
when Make decisions when age >= 18: show "Adult"
repeat Loop/repeat repeat 3 times: show "Hi"
think Add notes think "Remember this"

Math Operators

Operator Meaning Example
+ Addition 5 + 3
- Subtraction 10 - 4
* Multiplication 6 * 7
/ Division 20 / 4
^ Power 2 ^ 3
% Remainder 10 % 3

Comparison Operators

Operator Meaning Example
== Equal to age == 18
!= Not equal to name != "Bob"
> Greater than score > 90
< Less than price < 100
>= Greater or equal age >= 21
<= Less or equal temp <= 32

🌟 What's Next?

Now that you've mastered the basic commands, you're ready to:

  1. Learn about Variables - Variables and Data
  2. Master Decision Making - Making Decisions
  3. Explore Loops - Loops and Repetition
  4. Build Your First Project - First Project

Remember:

  • Practice makes perfect - Try all the examples
  • Experiment freely - Change values and see what happens
  • Don't be afraid of errors - They're learning opportunities
  • Ask for help - The community is here to support you

🎉 Congratulations!

You now know the essential Sona commands! These are the building blocks you'll use to create amazing programs. Every complex program starts with these simple commands.

Keep practicing, keep learning, and most importantly - have fun programming! 🚀


This guide is constantly updated based on feedback from our community. Have suggestions or found something confusing? Let us know!