![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python Homework
huanghh29
这个作者很懒,什么都没留下…
展开
-
第四次作业(2018-03-15,周三)
教材第四章习题4-2animals = ["cat", "dog", "godfish"]for animal in animals: print("A "+animal+" would make a great pet.")print("Any of these animals would make a great pet!")4-3for i in range(1,21): print原创 2018-03-15 17:05:57 · 163 阅读 · 0 评论 -
作业(2018-04-23,第八周周一)
16. 3Sum Closest16. 3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest...原创 2018-04-24 20:30:28 · 129 阅读 · 0 评论 -
Python作业(2018-05-16,第十一周周三)
Introduction to Python Exercise NumpyGenerate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m, for n = 200, m = 500.Exercise 9.1: Matrix operations Calculate ...原创 2018-05-17 15:14:40 · 141 阅读 · 0 评论 -
作业(2018-05-02,第九周周三)
Leetcode 46. PermutationsGiven a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]...原创 2018-05-06 12:25:05 · 103 阅读 · 0 评论 -
作业(2018-04-25,周三)
125. Valid PalindromeGiven a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note: For the purpose of this problem, we define empty string as valid...原创 2018-04-27 22:46:41 · 94 阅读 · 0 评论 -
作业(2018-04-28,周六)
817. Linked List ComponentsWe are given head, the head node of a linked list containing unique integer values.We are also given the list G, a subset of the values in the linked list.Return the number ...原创 2018-04-29 20:01:26 · 104 阅读 · 0 评论 -
Python Homework(2018-05-23,第十二州周周三)
MatplotlibEXExercise 11.1源代码import matplotlib as mplimport matplotlib.pyplot as pltimport mathimport numpy as npx = np.arange(0,2,0.02)plt.plot(x,np.sin((x-2)*(math.e**(-x*x))))plt.title("Plotti...原创 2018-05-29 09:45:31 · 161 阅读 · 0 评论 -
Python Homework(2018-06-06,第十五周周三)
pandas statsmodels seaborn用pandas中的DataFrame时选取行或列import numpy as npimport pandas as pdfrom pandas import Sereis, DataFrameser = Series(np.arange(3.))data = DataFrame(np.arange(16).reshap...原创 2018-06-12 10:29:42 · 286 阅读 · 0 评论 -
Python Homework(2018-05-30,第十三周周三)
Python之Scipy【解题思路】最小二乘法,使用numpy.linalg模块的lstsq函数。【具体代码】import numpy as npm = 20n = 10A = np.random.rand(m,n)b = np.random.rand(m,1)x,_,_,_ = np.linalg.lstsq(A,b,rcond=None)b_ = np.dot(A,x)sum =...原创 2018-06-02 15:22:15 · 250 阅读 · 0 评论 -
第十二次作业(2018-04-11,周三)
教材第十二章习题12-1 蓝色天空import sysimport pygamepygame.init()screen = pygame.display.set_mode((1200,800))pygame.display.set_caption("Alien Invasion")bg_color = (0,0,255)while True: for event in p...原创 2018-04-13 23:38:49 · 133 阅读 · 0 评论 -
第十一次作业(2018-04-09,周一)
教材第十一章习题11-1#city_functions.pydef city_func(city_name, country_name): return (city_name+","+country_name).title()#test_cities.pyimport unittestfrom city_functions import city_funcclass Test(unittes...原创 2018-04-12 17:05:08 · 122 阅读 · 0 评论 -
第八次作业(2018-03-28,周三)
教材第八章习题8-1def display_message(): print("What I learn in this chapter is function")display_message()8-2def favorite_book(book_name): print("One of my favorite books is "+book_name+".")favorite_book("Py...原创 2018-03-28 23:42:59 · 132 阅读 · 0 评论 -
第一次作业(2018-03-05,周一)
这是第一次上Python课,大致了解了Python语言的一些基本特征,课后又浏览了Python主页www.python.org,有了不少发现和收获。一、Python语言特性1、Python是一种解释型语言,与c/c++相比,Python是动态编译的,Python语言指令可以一边编写一边执行。2、Python的设计初衷之一就是增强程序的可读性,Python使用换行、缩进等空白字符来区分不同的...原创 2018-03-11 10:11:40 · 147 阅读 · 0 评论 -
第二次作业(2018-03-07,周三)
教材第二章练习题2-1message = "Hello, World!"print(message)2-2message = "Hello, World!"print(message)message = "My Name Is Python."print(message)2-3name = "Eric"print("Hello "+name+",would you like to learn so.原创 2018-03-11 10:51:26 · 111 阅读 · 0 评论 -
第三次作业(2018-03-12,周一)
教材第三章习题3-1names = ["huanghb", "huanghh", "huangjx", "huangj"]print(names[0])print(names[1])print(names[2])print(names[3])3-2names = ["huanghb", "huanghh", "huangjx", "huangj"]p原创 2018-03-12 18:56:23 · 180 阅读 · 0 评论 -
第五次作业(2018-03-19,周一)
教材第五章习题5-2print("huan"=="huan")print("huang"!="huang")print("Huan".lower()=="huan")print("Huang".lower()=="huan")print(0.2>0.21)print(-1<=0)print(6>3 and 6原创 2018-03-19 23:16:27 · 133 阅读 · 0 评论 -
第九次作业(2018-04-02,周一)
教材第九章习题9-1class Restaurant(): def __init__(self, restaurant_name, cuisine_type): self.restaurant_name = restaurant_name self.cuisine_type = cuisine_type def describe_restaurant(self): print("The re...原创 2018-04-08 13:08:04 · 117 阅读 · 0 评论 -
第六次作业(2018-03-21,周三)
6-1inf = {"first_name":"Huan", "last_name":"Huang", "age":20, "city":"GuangZhou"}print("first_name:"+inf["first_name"])print("last_name:"+inf["last_nam原创 2018-03-21 21:49:18 · 148 阅读 · 0 评论 -
第十次作业(2018-04-04,周三)
教材第十章习题10-1#learning_python.txtIn python you can do mathematical calculationsIn python you can keep accountsIn python you can design websitesIn python you can develop good games#test.pyfile_name = "le...原创 2018-04-08 20:12:13 · 192 阅读 · 0 评论 -
第七次作业(2018-03-26,周一)
教材第七章习题7-1message = input("What kind of car do you want?")print("Let me see if I can find a "+message+".")7-2number = int(input("How many people will have dinner?"))if number>8: print("Sorry, we d...原创 2018-03-26 17:26:02 · 205 阅读 · 0 评论 -
Python Homework(第十五周,周三)
题目代码import sklearnfrom sklearn import metrics#load a default datasetfrom sklearn import datasetsiris = datasets.load_iris()dataset = datasets.make_classification(n_samples=1000,n_features=10,n_in...原创 2018-06-19 22:03:39 · 128 阅读 · 0 评论