### 1. 找一句你钦佩的名人说的名言,将名人的姓名存储在变量famous_person 中,再将他说的名言存储在变量message 中,然后如下显示出该名人说了该名言(包括引号): xxx once said, "......"
时间: 2024-10-14 16:08:50 浏览: 37
乔布斯曾经说过:“Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do.” 可以用变量表示为:
```python
famous_person = "乔布斯"
message = "Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do."
print(f"{famous_person} once said, \"{message}\"")
```
相关问题
输入代码 找到你钦佩的名人说的一句名言,将这个名人的姓名和名言打印出来。输出应类似于这样(包括引号): Albert Einstein once said, “A person who never made a mistake never tried anything new
以下是一个Python代码示例,它会输出一个名人的姓名和他/她的一句名言:
```python
import random
# 定义一个包含名人和名言的字典
quotes = {
"Albert Einstein": "A person who never made a mistake never tried anything new.",
"Steve Jobs": "Innovation distinguishes between a leader and a follower.",
"Maya Angelou": "I've learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel.",
"Confucius": "It does not matter how slowly you go as long as you do not stop.",
"Nelson Mandela": "The greatest glory in living lies not in never falling, but in rising every time we fall."
}
# 随机选择一个名人和他的名言
selected_person, selected_quote = random.choice(list(quotes.items()))
# 打印结果,格式类似于:Albert Einstein once said, “A person who never made a mistake never tried anything new”
print(f'"{selected_person} once said, "{selected_quote}"')
```
这段代码会随机选择字典中的一个名人和对应的名言,并按照指定的格式打印出来。
阅读全文
相关推荐
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)