笨方法”学Python3,习题 01:第一个程序
1、print函数有什么作用?
2、代码怎么运行?(见习题 0)
3、#的作用是什么?
###文章末尾会做总结
一、基础代码
所写代码:
print("Hello World")
print("Hello Again")
print("I like typing this.")
print("Yay! Printing.")
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
---------------------------------------------------------------------------------------------------
应该看到的结果:
PS D:代码> & D:/软件/python/python.exe d:/代码/ex1.py
Hello World
Hello Again
I like typing this.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
二、巩固练习
1、让你的脚本再多打印一行
所写代码:
print("Hello World")
print("Hello Again")
print("I like typing this.")
print("Yay! Printing.")
print("I'd much rather you 'not'.")
print('I "said" do not touch this.')
print('My name is Jimmy.')
---------------------------------------------------------------------------------------------------
应该看到的结果:
PS D:代码> & D:/软件/python/python.exe d:/代码/ex1.py
Hello World
Hello Again
I like typing this.
Yay! Printing.
I'd much rather you 'not'.
I "said" do not touch this.
my name is Jimmy.
2&3、只打印其中一行和“#”的作用是什么
所写代码:
#print("Hello World")
##print("Hello Again")
###print("I like typing this.")
####print("Yay! Printing.")
######print("I'd much rather you 'not'.")
#######print('I "said" do not touch this.')
print('my name is #jimmy.')
---------------------------------------------------------------------------------------------------
应该看到的结果:
PS D:代码> & D:/软件/python/python.exe d:/代码/ex1.py
my name is #jimmy.
总结:
1、print可以打印一句话,以print("***")这种形式,把双引号换成单引号也可以。
2、#(octothorpe)可以让后面的代码无效,起到注释作用,但是放在print的双引号里没用。
3、书上得知SyntaxError 是语法错误,"^"标记错误位置。
^ v ^,知乎此系列文章内容均会在微信公众号中同步更新,公众号:小民有个小旮旯