Python is a powerful and fun programming language. But to use it effectively, we need to understand its rules. Let's explore some key concepts!
Python is case-sensitive. This means circle and Circle are different! Always pay attention to uppercase and lowercase letters.
In Python, the command (35) will draw a circle, but (35) will cause an error.
In Python, parentheses () are crucial. They're used to call functions and pass arguments. Remember: circle(35) works, but circle35 doesn't!
To draw a circle with radius 50, you should write:
Every character matters in Python. Missing a closing parenthesis or adding an extra space can change how your code behaves or cause errors.
Which of these commands is syntactically correct in Python?
Python uses indentation to define code blocks. Consistent indentation is crucial for your code to work correctly.
To create an indent:
Here's an example of indented code:
if True:
print("This line is indented")
print("This line is not indented")
Notice how the second line is indented (it starts further to the right). This indentation is crucial in Python!
In Python, how do you create an indent?
Let's reinforce what we've learned with some practice questions.
circle(35)
forward(20)
circle(35)
forward(20)
circle(35)
forward(20)
circle(35)
forward(20)
circle(35)