老早就开始学Python,现在分享一下学习代码。

前几节就是简单的输入输出练习,权当是熟悉一门新语言2333
###ex1.py

#print "Hello World!"
print "Hello Again"
print "I like typing this."
print "This is fun."
print '\n'
print 'Yay!Printing.'
print "I'd much rather you'not'."
print 'I "said" do not touch this.'
print '\n'

###ex3.py

print "I will now count my chickens:"print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4print "Now I will count the eggs:"print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6print "Is it true that 3 + 2 < 5 - 7?"print 3 + 2 < 5 - 7print "What is 3 + 2?",3 + 2
print "What is 5 - 7?",5 - 7print "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.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_drivenprint "There are", cars, "cars available."
print "There are only",drivers,"drivers available."
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",average_passengers_per_car,"in each car"

###ex5.py

# -*- coding: cp936 -*-
my_name = 'Hanxy Robin'
my_age = 19
my_height = 183
my_weight = 62
my_eyes = 'Black'
my_teeth = 'White'
my_hair = 'Black'print "Let's talk about %s." %my_name
print "He's %d cm tall." %my_height
print "He's %d kg heavey." %my_weight
print "He,s got %s eyes and %s hair." %(my_eyes , my_hair)print "%s" %my_eyes+my_hair

###ex6.py

x = "There are %d types of people." % 10binary = "binary"do_not = "don't"y = "Those who know %r and those who %s." %(binary,do_not)print x
print yprint "I said :%r." %x
print "I also said : %s." %yhilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"print joke_evaluation %hilariousw = "This is the left side of..."
e = "a string with a right side."print w + e

###ex7.py

print "Mary had a little lamb.",
print "Its fleece was white as %s." %'snow'
print "And everywhere that Mary went."
print "." * 10end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"print end1 + end2 + end3 + end4 + end5 + end6 ,
print end7 + end8 + end9 + end10 + end11 + end12

###ex8.py

formatter = "%s %r %r %r"print formatter %(1, 2, 3, 4)
print formatter %("one", "two",  "three" , "four")
print formatter %(True, False, False, True)
print formatter %(formatter, formatter, formatter, formatter)
print formatter %("I had this thing.","That you could type up right.","But it did't sing.",'So I said goodnight.')

###ex9.py

days = "Mon Tue Wed Thu Fri Sat Sun"
months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"print "Here are the days: ", days
print "Here are the months: ", monthsprint """
There's something going on here.
With the three double-quotes.
We'll be able to type as much as we like.
Even 4 lines if we want, or 5,or 6.
"""

###ex10.py

tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\ a \\ cat."fat_cat = """
I'll do a list:
\t* Cat food
\t* Fishies
\t* Catnip\n\t* Grass
"""print tabby_cat
print persian_cat
print backslash_cat
print fat_catwhile True:for i in ["*","^","_","^","*"]:print "%s\r" %i,

【Python】笨方法学Python学习笔记1相关推荐

  1. 笔记 | 笨方法学Python

    整理 | 阿司匹林 出品 | 人工智能头条(公众号ID:AI_Thinker) Python 有多好应该不用多说了,毕竟它是"钦定的"最接近 AI 的语言.(当然,PHP 才是最好 ...

  2. 《 笨方法学 Python 》_ 目录

    < 笨方法学 Python >(第 3 版)书中代码是 Python 2 版本,本着学习 Python 3 的目的,用 Python 3 完成本书的习题,代码也已上传到 Github. 作 ...

  3. 笨方法学Python(二)

    笨方法学Python,习题16 - 21 版本:3.8.0 编辑器:Visual Studio Code 习题16到21讲的是文件的读写和函数的基础,可以通过一个实例来同时练习他们.在下列情景中,我将 ...

  4. 笨方法学python 习题37

    还是在笨方法学python中... 本节的习题是看一下作者列出的python中的各种运算符,尝试来理解这些符号. 在这里,我只列出了一些自己不会的,通过查百度得到得答案,这里来列举一下. (另外有不怎 ...

  5. 笨方法学python 15章疑问

    ** 笨方法学python 15章疑问 在15张中教我们读取文件,但是当我测试能否打开我之前写的py格式的文本时出现了这一幕 文件打开后然后又出现了 File "15.py", l ...

  6. 《笨方法学python》_《笨办法学Python》 第46课手记

    <笨办法学Python> 第46课手记 这节课制作了一个Python的项目骨架,花了我一个晚上和一个早上的时间,原因是我下载的pdf里面只有OX S的命令行,而没有win下的.我为此在知道 ...

  7. 笨方法学python习题4

    变量和命名 #笨方法学python_习题4#定义变量 cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90#计算 cars_not_ ...

  8. 笨办法学python__学习笔记

    笨办法学python –20190307 之前开始学习python过多次,每次都以失败告终.其实我有计算机语言的基础,高中时在步步高词典上是basic写过小程序,大学时自学C.不过学C的时候不得要领, ...

  9. 笨方法学python第四版当当_“笨办法”学Python(第3版)

    ZedShaw完善了这个堪称世上较好的Python学习系统.只要跟着学习,你就会和迄今为止数十万Zed教过的初学者一样获得成功. 在这本书中,你将通过完成52个精心设计的习题来学会Python.阅读这 ...

  10. python求15 17 23 65 97的因数_笨方法学python,Lesson15,16,17

    Exercise 15 代码 from sys import argv script, filename = argv txt = open(filename) print "Here is ...

最新文章

  1. iOS10 UI教程视图和子视图的可见性
  2. 西安python培训班多少钱-西安python正规培训机构
  3. 基于案例贯通 Spark Streaming 流计算框架的运行源码
  4. 二进制python_利用Python对二进制数据进行按位处理
  5. 理解Go Interface
  6. spring-junit4_基于Spring的应用程序-迁移到Junit 5
  7. 如何指南:Apache Drill入门
  8. django mysql settings
  9. 神通数据库打开服务_数据库周刊30丨数据安全法草案将亮相;2020数据库产业报告;云南电网上线达梦;达梦7误删Redo…...
  10. springboot配置C3P0数据库连接池
  11. 时域进行两次傅里叶变换
  12. 数字图像处理课程设计-疲劳检测系统
  13. Python中常用的四个小技巧总结
  14. Frequent Subsets Problem
  15. 2022-2028年中国固体浮力材料行业竞争现状及投资决策建议报告
  16. TikTok三大流行趋势 钛动带你看懂TikTok
  17. DHCP服务器配置windows2016
  18. Windows 10 下 TeXstudio 深色背景主题的设置方法
  19. 关于Java,你想知道的一切,这里说透了
  20. 我们都忽略了Html5的力量,如果只看成一种技术就大错特错了!

热门文章

  1. 正弦分析2--三角函数线
  2. java号码分身_电话号码分身
  3. MATLAB怎么计算曲面面积,Matlab曲面面积估计.doc
  4. 脱单攻略 | 如何找到心仪的另一半?
  5. torch-sparse安装教程
  6. Java:Java静态多态性与动态多态性
  7. LeetCode刷题之575.分糖果
  8. 留言滚动栏,html滚动代码,滚动留言代码
  9. 【无标题】输入和输出
  10. FPGA的矩阵键盘驱动( 修正版)