程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

笨办法学Python 3 习题14

发布于2020-02-24 23:28     阅读(2084)     评论(0)     点赞(1)     收藏(2)


[交作业啦]
ex14.py

from sys import argv

script, user_name = argv
prompt = '> '

# f-string 格式化字符串
print(f"Hi {user_name}, I'm the {script} script.")
print("I'd like to ask you a few questions.")
print(f"Do you like me {user_name}?")
# 使用input()接受一个标准输入数据,以prompt作为提示符,将其赋值给变量likes
likes = input(prompt)

print(f"Where do you live {user_name}?")
lives = input(prompt)

print("What kind of computer do you have?")
computer = input(prompt)
# 将已有变量插入格式化字符串中
print(f"""
Alright, so you said {likes} about liking me.
You live in {lives}. Not sure where that is.
And you have a {computer} computer. Nice.
""")
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

会话

PS E:\lpthw> python ex14.py lym
Hi lym, I'm the ex14.py script.
I'd like to ask you a few questions.
Do you like me lym?
> yes
Where do you live lym?
> bj
What kind of computer do you have?
> G470

Alright, so you said yes about liking me.
You live in bj. Not sure where that is.
And you have a G470 computer. Nice.

PS E:\lpthw>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
发布了15 篇原创文章 · 获赞 0 · 访问量 278


所属网站分类: 技术文章 > 博客

作者:j878

链接:https://www.pythonheidong.com/blog/article/232739/c8182ada98108844c52a/

来源:python黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

1 0
收藏该文
已收藏

评论内容:(最多支持255个字符)