Đi bộ đến ba dấu X và nói “Xin chào” để hoàn thành cấp độ.
Đi đến ba dấu X trên mặt đất và gọi ra bằng cách sử dụng hàm speak()
khi đứng trên chúng.
Để gọi ra “Xin chào”, bạn cần sử dụng hàm speak như sau:
player.speak("Hello")
Sách Mã
Level 5: In Python, you can use the `print()` function to display text or other information on the screen. To print a string, enclose it in quotation marks. For example:
```python
print("Hello, world!")
```
This will output:
```
Hello, world!
```
### Using Variables
You can also use variables to store text or numbers and then print them. For instance:
```python
message = "Welcome to the course!"
print(message)
```
### Printing Multiple Items
You can print multiple items by separating them with commas. Each item will be separated by a space in the output:
```python
first_name = "Jane"
last_name = "Doe"
print("Hello,", first_name, last_name)
```
This will output:
```
Hello, Jane Doe
```
### Print Function with Formatting
The `print()` function can be used with f-strings for formatting, which allow you to embed expressions inside string literals, using curly braces. Here's an example:
```python
name = "Alice"
age = 30
print(f"My name is {name} and I am {age} years old.")
```
This will output:
```
My name is Alice and I am 30 years old.
```
### Special Characters
You can include special characters in strings, like newlines (`\n`) or tabs (`\t`). Here's an example with a newline:
```python
print("Hello, world!\nHow are you?")
```
The output will be:
```
Hello, world!
How are you?
```
This is a basic introduction to printing in Python. As you continue learning, you'll encounter more ways to control and format your printed output. | Giới thiệu về Python