没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
1
Python 入门教程 1 ---- Python Syntax
1 Python 是一个高效的语言,读和写的操作都是很简单的,就像普通的英语一样
2 Python 是一个解释执行的语言,我们不需要去编译,我们只要写出代码即可运行
3 Python 是一个面向对象的语言,在 Python 里面一切皆对象
4 Python 是一门很有趣的语言
5 变量:一个变量就是一个单词,只有一个单一的值
练习:设置一个变量 my_variable,值设置为 10
[cpp]
#Write your code below!
my_variable = 10
3 第三节
1 Python 里面有三种数据类型 interage , floats , booleans
2 Python 是一个区分大小写的语言
3 练习
1 把变量 my_int 值设置为 7
2 把变量 my_float 值设置为 1.23
3 把变量 my_bool 值设置为 true
[python]
#Set the variables to the values listed in the instructions!
my_int = 7
my_float = 1.23
my_bool = True
2
6 Python 的变量可以随时进行覆盖
2 练习:my_int 的值从 7 改为 3,并打印出 my_int
[python]
#my_int is set to 7 below. What do you think
#will happen if we reset it to 3 and print the result?
my_int = 7
#Change the value of my_int to 3 on line 8!
my_int = 3
#Here's some code that will print my_int to the console:
#The print keyword will be covered in detail soon!
print my_int
7 Pyhton 的声明和英语很像
8 Python 里面声明利用空格在分开
3 练习: 查看以下代码的错误
[python]
def spam():
eggs = 12
return eggs
print spam()
9 Python 中的空格是指正确的缩进
2 练习: 改正上一节中的错误
3
[python]
def spam():
eggs = 12
return eggs
print spam()
10 Python 是一种解释执行的语言,只要你写完即可立即运行
2 练习:设置变量 spam 的只为 True,eggs 的值为 False
[python]
spam = True
eggs = False
11 Python 的注释是通过“#”来实现的,并不影响代码的实现
2 练习:给下面的代码加上一行注释
[python]
#this is a comments for Python
mysterious_variable = 42
12 Python 的多行注释是通过“ """ """ ”来实现的
2 练习:把下面的代码加上多行
[python]
"""
this is a Python course
"""
a = 5
4
13 Python 有 6 种算术运算符+,-,*,/,**(幂),%
2 练习:把变量 count_to 设置为 1+2
[python]
#Set count_to equal to 1 plus 2 on line 3!
count_to = 1+2
print count_to
14 Python 里面求 x^m,写成 x**m
2 练习:利用幂运算,把 eggs 的值设置为 100
[python]
#Set eggs equal to 100 using exponentiation on line 3!
eggs = 10**2
print eggs
1 练习:
1 写一行注释
2 把变量 monty 设置为 True
3 把变量 python 值设置为 1.234
4 把 monty_python 的值设置为 python 的平方
[python]
#this is a Python
monty = True
python = 1.234
monty_python = python**2
5
Python 入门教程 2 ---- Tip Calculator
1 把变量 meal 的值设置为 44.50
[python]
#Assign the variable meal the value 44.50 on line 3!
meal = 44.50
1 把变量 tax 的值设置为 6.75%
[python]
meal = 44.50
tax = 6.75/100
1 设置 tip 的值为 15%
[python]
#You're almost there! Assign the tip variable on line 5.
meal = 44.50
tax = 0.0675
tip = 0.15
1 把变量 meal 的值设置为 meal+meal*tax
[python]
#Reassign meal on line 7!
meal = 44.50
tax = 0.0675
tip = 0.15
meal = meal+meal*tax
设置变量 total 的值为 meal+meal*tax
[python]
#Assign the variable total on line 8!
meal = 44.50
剩余68页未读,继续阅读
资源评论
- 最后的倔强之读研2023-06-20这个资源对我启发很大,受益匪浅,学到了很多,谢谢分享~
梦想是优秀社畜
- 粉丝: 63
- 资源: 30
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功