广告区

广告区


本站消息

站长简介/公众号

关注本站官方公众号:程序员总部,领取三大福利!
福利一:python和前端辅导
福利二:进程序员交流微信群,专属于程序员的圈子
福利三:领取全套零基础视频教程(python,java,前端,php)

  价值13000svip视频教程,python大神匠心打造,零基础python开发工程师视频教程全套,基础+进阶+项目实战,包含课件和源码

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

+关注
已关注

分类  

暂无分类

标签  

暂无标签

日期归档  

2021-07(1)

2021-08(12)

笨办法学Python 3 习题14

发布于2020-02-24 23:28     阅读(1661)     评论(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个字符)