菜鸡学Python

前言
大一暑假疫情原因推迟开学,希望两周之内能够自学Python的基本操作。后续开学时期会学习爬虫相关内容。每天学习Python并编写blog打卡记录自己的学习生活。

下载和安装

Python3下载地址
pycharm下载地址

安装教程

本来是想自己写的,但菜鸟教程YYDS!
请移步菜鸟教程学习详细安装步骤

打卡代码

demo1 :各种输出方式

# 开发时间:2021/8/24 11:18
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 博主链接:https://blog.csdn.net/qq_45148277
print("hello world")
print(1+2)
print(3.5)
fp=open('D:/text.txt','a+')
print('hello world',file=fp)
fp.close()
print('hello','world','python!')

demo2:转义字符的复习

# 作者:邵昱原
# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/24 15:54
print("hello\nworld")
print("hello\tworld")
print("hello\rworld")
print("hello\bworld")
print("http:\\\\www.baidu.com")
print("老师说:\"大家好\"")
#原字符,在字符串前加r或R使字符串内的反斜杠无效,但最后一个字符不能是反斜杠(可以有两个)。

demo3:关键字的记录

# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/24 16:13
import keyword
print(keyword.kwlist)

demo4:浮点数的计算


# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/25 15:47
n1=2.2
n2=1.1
n3=2.1
print(n1+n2)
print(n2+n3)
from decimal import Decimal
print(Decimal('1.1')+Decimal('2.2'))

demo5:强制类型转换

# 作者:邵昱原
# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/25 15:51
name='邵昱原'
age=21
num='123'
print('我叫'+name+',今年'+str(age)+'岁')
print(int(num))

demo6:输入语句


# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/25 16:14
a=input()
b=input()
a=int(a)
b=int(b)
print(a+b)

demo7:关于运算符中除和取余与C++有何不同


# 博主链接:https://blog.csdn.net/qq_45148277
# email:daozhang123@foxmail.com
# 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
# 开发时间:2021/8/25 16:43
#运算时要向下取整
print(9//4)
print(-9//-4)

print(-9//4)
print(9//-4)

print(9%-4)  #公式 余数=被除数-除数*商 9-(-4)*(-3)=-3
print(-9%4)

打卡完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值