栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python学习第一天

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python学习第一天

Python学习第一天记录

Python学习1

根据笨方法学Python3进行练习学习,主要记录自己的学习历程和期间遇到的问题。

练习1.第一个程序

ex1.py

#print("Hello World!")
#print("Hello Aagain.")
#print("I Like typing this.")
#print("This is fun.")
#print("Yay! Printing.")
#print("I'd much rather you 'not'.")
#print("I'said' do  not touch this.")
print("test")

练习2.注释和 # 号

ex2.py

# A comment,this is so you can read your program later.
# Anything after the # ignored by python.

print("I could have code like this.") # and the comment after 5
# You can also use a comment to "disable" or comment out code
# print("This won't run.")

print("This will run.")
练习3.数字和数学

ex3.py

print("I will now count my chickens:")

print("Hens", 25 + 30 / 6)
print("Roosters", 100 - 25 * 3 % 4)

print("Now I will count the eggs:")

print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 )

print("Is it true that 3 + 2 < 5 - 7?")

print("3 + 2 < 5 - 7")

print("What is 3 + 2?", 3 + 2)
print("What is 5 - 7?", 5 - 7)

print("Oh, that's why it's False.")

print("How about some more.")

print("Is it greater?", 5 > -2)
print("Is it greater or equal?", 5 >= -2)
print("Is it less or equal?", 5 <= -2)
变量和名字

ex4.py

cars = 100 #车的数量
space_in_a_car = 4 #每个车的容量
drivers = 30 #司机数量
passengers = 90 #乘客数量
cars_not_driven = cars - drivers #不能使用的车
cars_driven = drivers #可使用的车
carpool_capacity = cars_driven * space_in_a_car #可使用车的总容量
averge_passengers_per_car = passengers / cars_driven #每辆车的乘客数量


print("There are", cars, "cars available.")
print("There are only", drivers, "drivers avaiable.")
print("There will be", cars_not_driven, "empty cars today.")
print("We can transport", carpool_capacity, "people today.")
print("We have", passengers, "to carpool today.")
print("We need to put about", averge_passengers_per_car,
      "in each car.")
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/892953.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号