第一次课:python
日期:2024.7.11
内容:python环境配置以及基础学习
课程内容
Python入门
直播时间:7月11日 19:00-20:00
回放链接:https://www.bilibili.com/video/BV1wE421P762/
课外资料:
聪明办法学Python:https://datawhalechina.github.io/learn-python-the-smart-way-v2/
菜鸟教程:https://www.runoob.com/python3/python3-basic-syntax.html
准备工作
VSCode下载:https://code.visualstudio.com/Download
Miniconda下载:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Windows-x86_64.exe
课堂笔记代码:
print("helloword")
a=123
b=12.3
c="heiwhfa"
#菜鸟教程Python3(基本教程)
print(a==1123)#布尔型变量
d=[1,2,2,3]
#定义函数
def function():
return 123
print((function()))
#文件操作
name='123'
with open("123.txt",'w')as f:
f.write(name)
with open("123.txt",'r')as f:
print("123.txt")
Jupyter Notebook 使用
安装
pip install jupyter
打开
jupyter notebook
作业
要求: 必须使用Jupyter Notebook完成,保留运行记录,交作业时提交.ipynb文件
作业1: 使用循环嵌套逻辑输出9x9乘法表,保存到本地文件(res.txt ,存的内容是九九乘法表),再读出来输出
完成情况:
i=1
while i<=9:
j=1
while j<=i:
print("%s*%s=%s"%(j,i,j*i),end="\t")
j+=1
i+=1
print("")
Q&A
安装Jupyter时,报错:time out
这是由于pip的安装源默认是官网,在海外,连接比较慢导致的。
可以在cmd进入环境后执行以下代码设置到清华源,然后再安装Jupyter即可
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple