自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(28)
  • 收藏
  • 关注

原创 ubuntu虚拟环境及 django项目

建立:1. 安装virtualenvpip install --user virtualenv2. 创建virtualenv环境virtualenv ll_env激活:source ll_env\bin\activate关闭:deactivate安装django:pip install Django创建django项目:django_ad...

2020-02-06 16:24:54 137

原创 python3 常用库安装 环境 ubuntu64位

matplotlib:sudo apt-get install python3-tkpip install --user matplotlibpygame: ...

2020-02-02 12:48:33 275

原创 第十五周作业

题目描述:代码如下:from sklearn import datasets from sklearn import cross_validation from sklearn.naive_bayes import GaussianNB from sklearn.svm import SVC from sklearn.ensemble import RandomForestClas...

2018-06-19 16:42:55 278

原创 第十四周作业

代码:#matplotlib inlineimport randomimport numpy as npimport scipy as spimport pandas as pdimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as smimport statsmodels.f...

2018-06-12 16:57:56 186

原创 第十三周作业

1.代码如下:import numpy as np import scipy.linalg as sla m = 10 n = 5 A = np.random.random((m, n)) b = np.random.random((m, 1)) x = sla.lstsq(A, b)[0] print(np.linalg.norm(np.dot(A, x)...

2018-06-06 01:59:39 175

原创 第十二周作业 matplotlib

1、代码如下:import matplotlib.pyplot as pltfrom math import *input_values = [i/10000 for i in range(1, 20000)]y = [pow(sin(x-2), 2)*pow(e, -pow(x, 2)) for x in input_values]plt.plot(input_values, y, ...

2018-05-29 22:09:15 272

原创 第十一周作业

9.1代码如下:import numpyA = numpy.zeros([200, 500])B = numpy.zeros([500, 500])for i in range(200): for j in range(500): A[i][j] = numpy.round(numpy.random.normal(0, 1, 1),2)for i in range(500): ...

2018-05-20 19:24:09 150

原创 第八周 周六作业

题目描述:代码:class Solution: def matrixReshape(self, nums, r,c): if r*c != len(nums)*len(nums[0]): return nums else: row = 0 col = 0 answer = [] for i in range(0,r): temp = [] f...

2018-04-29 17:00:35 129

原创 第八周 周三作业

题目描述:代码:class Solution: def pivotIndex(self, nums): if len(nums) == 0: return -1 if sum(nums[1:])==0: return 0 total = sum(nums) now = nums[0]*2; for i in range(1, len(nums)-1): if...

2018-04-29 16:34:32 147

原创 第八周 周一作业

题目描述:代码:class Solution: def removeDuplicates(self, nums): i = 1 while i<len(nums): if nums[i]>nums[i-1]: i += 1 else: nums.remove(nums[i]) return len(nums)测试代码:from solutio...

2018-04-29 16:13:08 152

原创 第六周作业

11-1 城市和国家:'''module city_functions.py'''def city_country(city, country): return str(city) + ", " + str(country) '''文件名: test_cities.py'''import unittestfrom city_functions import city_country...

2018-04-10 21:11:59 96

原创 第五周

9-1 餐馆:class Restaurant(): def __init__(self, restaurant, cuisine_type): self.restaurant = restaurant self.cuisine_type = cuisine_type def describe_restaurant(self): print(self.restaurant, s...

2018-04-06 13:58:28 145

原创 第四周作业

7-1 汽车租赁:kind = input("What kind of car do you want to rent?")print("Let me see if I can find you a " + kind + ".")运行结果:7-2 餐桌订位:people = input("How many people have lunch?") people = int(people)i...

2018-03-31 15:24:01 166

原创 第三周作业

5-1 条件测试:car = 'subaru'print("Is car == 'subaru'? I predict True.")print(car == 'subaru')print("\nIs car == 'audi'? I predict False.")print(car == 'audi')print("\nIs car == 'A'? I predict False...

2018-03-21 22:30:40 194

原创 第二周作业

3-1 姓名:代码:names = ['Hong siyuan', 'lin dongwei', 'chen peipeng', 'li yinwei']for name in names: print(name.title())运行结果:3-2 问候语:代码:names = ['Hong siyuan', 'lin dongwei', 'chen peipeng', 'li yinwei']...

2018-03-15 21:13:02 273

原创 2-11:Python之禅

在Python终端会话中执行命令 import this,并粗略的浏览一下其他指导原则。命令行及运行结果:

2018-03-09 12:29:21 727

原创 2-10:添加注释

题目描述:选择你编写的两个程序,在每个程序中都至少添加一条注释。如果程序太简单,是在没有什么需要说明的,就在程序文件开头加上你的姓名和当前日期,再用一句话阐述程序的功能。代码如下:print(5 + 3) print(10 - 2) print(2 * 4) # Explict is better than implict print(int(16 / 2)) # output ...

2018-03-09 12:26:42 432

原创 2-9:最喜欢的数字

题目描述:将你最喜欢的数字储存在一个变量中,再使用这个变量创建一个消息,指出你最喜欢的数字,然后将这条消息打印出来。代码如下:favourite_num = 5message = "My favourite number is " + str(favourite_num) + "."print(message)运行结果:...

2018-03-09 12:19:35 2383

原创 2-8:数字8

题目描述:编写四个表达式,它们分别使用加法、减法、乘法和除法运算,但结果都是数字8。为使用print语句来显示结果,务必将这些表达式用括号括起来,也就是说,你应该编写四行类似于下面的代码:print(5 + 3)代码如下:print(5 + 3)print(10 - 2)print(2 * 4)# Explict is better than implictprint(int(16 / 2...

2018-03-09 12:14:58 696

原创 2-7:剔除人名中的空白

题目描述储存一个人名,并在其开头和末尾包含一些空白字符。务必至少使用字符组合"\t"和"\n"各一次。打印这个人名,以显示其开头和末尾的空白。然后,分别使用剔除函数lstrip(),rstrip()和strip()对人名进行处理,并将结果打印出来。代码如下:name = "\n\t justin \n \n\t"print(name)print(name.lstrip())print(nam...

2018-03-09 12:05:26 2148

原创 2-6:名言2:

题目描述:重复练习2-5,但将名人的姓名储存在一个变量famous_person中,再创建要显示的消息,将其储存在变量message中,然后在打印这条消息。代码如下:famous_person = 'Albert Enstein'message = 'A person who never made a mistake never tried anythin new.'print(famous_...

2018-03-09 11:52:50 504

原创 2-5:名言

题目描述:找出一个你钦佩的名人说的名言,将这个名人的姓名和他的名言打印出来。输出应类似下面这样(包括括号):Albert Einstein once said, "A person who never made a mistake never tried anything new."代码如下:person_and_saying = 'Albert Enstein once said, "A per...

2018-03-09 11:47:15 1088

原创 2-4:调整名字的大小写

题目描述:将一个人名储存到一个变量中,再以小写,大写,首字母大写的方式显示这个人名。代码如下:name = "justin"print(name.lower())print(name.upper())print(name.title())运行结果:...

2018-03-09 11:38:01 628

原创 2-3:个性化消息

题目描述:将用户的姓名存到一个变量中,并向该用户显示一条消息。显示消息的应非常简单,如“Hello Eric,would you like to learn some Python today”代码如下:name = "eric"print("Hello " + name.title() + ", would like to learn some Python today?")运行结果:...

2018-03-08 23:50:23 1070

原创 2-2:多条简单消息

将一条消息储存到变量中,将其打印出来,再将变量的值修改为一条新消息,并将其打印出来。代码如下:message = "hello, Miss right"print(message)message = "hello, my lady"print(message)运行结果如下:...

2018-03-08 23:48:04 649

原创 2-1:简单消息

将一条消息储存到变量,再将其打印出来。message = "hello, Miss right"print(message)运行结果:

2018-03-08 23:43:25 284

原创 假如我成为一个python高手

人总要有梦想,万一实现了呢?假如我成为一个python高手,我要做一款风靡全球的游戏,不用太风靡,就跟英雄联盟差不多就行啦。假如我成为一个python高手,我要做一个性能很高且安全性很高的网站,不轻易被攻击或崩溃。假如我成为一个python高手,我要用爬虫充分利用线上资源,为我的程序和生活服务。梦想的想象固然容易,而梦想的实现需要的是努力。...

2018-03-08 23:36:18 370

原创 浏览python网页之获

浏览python网页(点击打开链接),首先发现的是Download,发现有众多版本的python,最新版本是python3.6.4,而我也是选择下载该版本。接着,发现python有许多有趣的真实故事,致使python成为一门很灵活的语言,引用该网站的语言就是Python is a programming language that lets you work more quickly and in...

2018-03-08 23:17:52 161

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除