
笨方法学Python
while_false_
一起来刷题呀
展开
-
Python学习笔记(笨方法学Python3)-习题0:准备工作
准备工作1、安装Atom文本编辑器(http://atom.io)2、下载安装Python(htttp://www.python.org/downloads/release/python-360)3、安装时记得勾选“add Python XXX to PATH”4、测试Python是否安装完成(Windows - Powershell 输入Python)一些文本编辑器:名称...原创 2019-04-04 14:23:13 · 890 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题20:函数和文件
from sys import argvsrcipt, input_file = argvdef print_all(fp): print(fp.read())def print_oneline(line_count,fp): print(line_count, fp.readline(), end = "")def rewind(fp): fp.seek(...原创 2019-08-08 10:25:30 · 272 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题21:函数可以返回某些东西
def add(a, b): print(f"Adding {a} + {b}") return a + bdef subtract(a, b): print(f"Substracting {a} - {b}") return a - bdef multiply(a, b): print(f"Multiplying {a} * {b}") r...原创 2019-08-08 14:39:51 · 313 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题12:提示别人
age = input("how old are you? ")height = input("how tall are you? ")weight = input("how much do you weight? ")print(f"so, you're {age} old, {height} tall and {weight} heavy.")print("how old are y...原创 2019-08-06 14:30:22 · 245 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题13:参数、解包和变量
from sys import argv # 解包script, one, two, three = argv print("script: ",script)print("1: ",one)print("2: ",two)print("3: ",three)文件保存为ex13.py配置入参:结果为:* import 语句,是将python的特性引入脚本的方法* a...原创 2019-08-06 15:16:01 · 570 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题14:提示和传递
from sys import argvscript, user_name = argvprompt='> ' # 单引号一般用在字符串比较短的情况下print(f"Hi {user_name}, i'm the {script} script.")print("i'd like to ask you a few questions.")print(f"do you like...原创 2019-08-06 15:48:12 · 292 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题15:读取文件
from sys import argvscript,file_name = argvtxt = open(file_name)print(f"here your file {file_name}.")print(txt.read())txt.close()file_again=input('>')txt_again=open(file_again)print(tx...原创 2019-08-06 16:36:43 · 376 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题16:读写文件
from sys import argvscript,filename = argvprint(f"we're going to erase {filename}.")print("if you don't want that, hit CTRL-C(^c).")print("if you do want that, hit return.")input("?")print("...原创 2019-08-06 18:04:51 · 310 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题17:更多文件操作
from sys import argvfrom os.path import existsscript, from_file, to_file = argvprint(f"Copping from {from_file} to {to_file}")#we could do these two on one line, how?in_file = open(from_file)...原创 2019-08-07 14:59:54 · 250 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题23:字符串、字节串和字符编码
import sysscript, encoding, error=sys.argvdef main(language_file, encoding, errors): line=language_file.readline() if line: print_line(line, encoding, errors) return main(l...原创 2019-08-14 10:52:20 · 800 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题19:函数和变量
def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"you have {cheese_count} cheeses!") print(f"you have {boxes_of_crackers} boxes of crackers!") print("Man that's enough for ...原创 2019-08-08 09:59:58 · 196 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题11:提问
print("How old are you?", end = ' ')age = input()print("How tall are you?", end = ' ')height = input()print("How much do you weigh?", end = ' ')weight = input()print(f"So, you're {age} old, {he...原创 2019-05-20 17:59:00 · 419 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题9:打印,打印,打印
# Here's some new strange stuff, remember type it exactly.days = "Mon Tue Wed Thu Fri Sat Sun"months = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"print("Here are the days:", days)print("Here are th...原创 2019-05-07 14:52:26 · 273 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题1:第一个程序
第一个程序print("Hello World!")print("Hello again")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.')将这...原创 2019-04-04 14:41:16 · 307 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题2:注释和#号
注释和#号# A comment, this is so you can read your program later.# Anything after the # is ignored by python.print("I could have code like this,") # and the comment after is ignored# You can also us...原创 2019-04-04 14:58:54 · 496 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题3:数字和数学计算
数字和数学计算print("I will now count my chickens:")print("Hens", 25 + 30 / 6)print("Roosters", 100 - 25 * 3 % 4)print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)print("Is it true that 3 + 2 < 5 - 7?")pr...原创 2019-04-04 16:20:12 · 294 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题4:变量和命名
变量和命名cars = 100space_in_a_car = 4.0drivers = 30passengers = 90cars_not_driven = cars - driverscars_driven = driverscarpool_capacity = cars_driven * space_in_a_caraverage_passengers_per_car = p...原创 2019-04-08 11:32:04 · 350 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题5:更多的变量和打印
my_name = 'Zed A. Shaw'my_age = 35 # not a liemy_height = 74 # inchesmy_weight = 180 # lbsmy_eyes = 'Blue'my_teeth = 'White'my_hair = 'Brown'print(f"Let's talk aboult {my_name}.")print(f"He's...原创 2019-04-17 10:07:09 · 324 阅读 · 2 评论 -
Python学习笔记(笨方法学Python3)-习题10:那是什么
tabby_cat = "\tI am 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_c...原创 2019-05-08 10:16:55 · 244 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题6:字符串和文本
Python可以通过文本里的双引号(““”)或者单引号(‘’)识别出来。特别的字符串类型:1、“f-string” 例: f"some stuff here {avariable}"2、.format()语法的格式化方法types_of_people = 10x = f"There are {types_of_people} types of people."binary = "b...原创 2019-05-07 14:13:05 · 590 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题7:更多打印
print("Mary had a little lamb.")print("Its fleece was white as {}.".format('snow'))print("And everywhere that Mary went.")print("." * 10) # what'd that do ?end1 = "C"end2 = "h"end3 = "e"end4 =...原创 2019-05-07 14:27:14 · 387 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题8:打印,打印
formatter = "{} {} {} {}"print(formatter.format(1,2,3,4))print(formatter.format("one", "two", "three", "four"))print(formatter.format(True, False, False, True))print(formatter.format(formatter, f...原创 2019-05-07 14:39:47 · 271 阅读 · 0 评论 -
Python学习笔记(笨方法学Python3)-习题18:命名、变量、代码和函数
# this one is like your scripts with argvdef print_two(*args): arg1,arg2=args print(f"arg1:{arg1}, arg2:{arg2}")def print_two_again(arg1, arg2): print(f"arg1:{arg1}, arg2:{arg2}")def ...原创 2019-08-07 17:07:31 · 281 阅读 · 1 评论