name=input("What is your name?") age=input("How old are you?") print ("Your name is:"),name print ("You are"+age+"years old.") after_ten=int(age)+10 print("You will be"+str(after_ten)+"years old
时间: 2023-07-19 19:08:03 浏览: 43
你的代码最后一行缺少一个右括号,应该是这样的:
```
name = input("What is your name?")
age = input("How old are you?")
print("Your name is:", name)
print("You are " + age + " years old.")
after_ten = int(age) + 10
print("You will be " + str(after_ten) + " years old.")
```
这样就能正常执行了。注意要把输入的年龄转换为整数类型,才能进行数学运算。另外,字符串拼接时需要注意空格的位置。
相关问题
name = ??? age = ??? print(f"Hello, My name is ??? and I'm ??? years old.")
To fill in the missing values for `name` and `age`, you need to provide the specific values you want to use. For example:
```python
name = "John"
age = 25
print(f"Hello, My name is {name} and I'm {age} years old.")
```
Replace "John" with the desired name and 25 with the desired age. The print statement will display: "Hello, My name is John and I'm 25 years old."
name = input() isFound = for : if : isFound = True print(contact["mobile"]) break if isFound != True: print("用户不存在
这段代码似乎不完整,缺少关键的变量和循环。但是,我可以给您提供一个基本的电话本查询的Python代码示例,帮助您了解如何实现:
```
# 定义一个电话本
contacts = {
"张三": "123456789",
"李四": "987654321",
"王五": "456789123"
}
# 获取用户输入的名字
name = input("请输入要查询的联系人姓名:")
# 遍历电话本,查找是否有匹配的联系人
isFound = False
for contact in contacts:
if name == contact:
isFound = True
print(contacts[contact])
break
# 输出查询结果
if not isFound:
print("用户不存在")
```
您可以根据自己的需要对代码进行修改和优化。