云学编程的第2天—【微软官方python入门教程 P5-P6笔记】2021-11-02 print

P5学会使用print

`Display a message: print

You can use either single quotes or double quotes to enclose your strings;Consistent

Eg:

print(‘hello world single quotes’)
print(“hello world double quotes”)  

`Ask  for information from the user: input function

name = input(‘please enter your name:’)

print(name)

Whatever value is passed back by the user will then be put into that name variable

`Blank line: print() ; \n slash n means insert a new line here

Eg:

 print(‘hello world’)

     print()

     printI(‘blank line\nin the middle of string’)

`Debugging with print figure out where my code blew up:

print('Adding numbers')
x=42+206
print('performing division')
y=x/0
print('Math complete')

Adding numbers

Performing division

Traceback(most recent call last):            #读取文件时遇到文件结尾而无法读取

    File"demo.py",line 4,in<modle>

       y=x/0

ZeroDivisionEroor: float division by zero     #除数为0报错

P6 第一次在VSC中敲代码

`create a folder on your file system: open file

`new file

`save (keyboard shortcuts:command+s) 

 

`clear the screen: cls (linux是clear)

`debug the code:use print statements as a debugging tool 

print('adding numbers')
x=532+12
print('dividing numbers')
y=x/0
print('yay I did math')

adding numbers
dividing numbers
Traceback (most recent call last):
  File "/Users/huaweimatebook16/python入门/print('hallo world').py", line 4, in <module>
    y=x/0
ZeroDivisionError: division by zero

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值