自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 2021-01-02

有穷自动机解决字符串转整数1.要求第一非空字符为正负号后跟连续数字,非数字字符及其后忽略 第一非空数字后跟连续数字,非数字字符及其后忽略 范围表示int上下界,超出则以上下界值表示 其余非法,0表示2.方法1.直接法 针对各种条件,直接编写(python):空字符串 首非空字符为不是数字及正负号 所转换数字越界 连续数字后接非数字字符 def myAtoi(s): """ :type s: str ...

2021-01-02 22:14:02 111

原创 第十四周作业

Anscombe's quartetAnscombe's quartet comprises of four datasets, and is rather famous. Why? You'll find out in this exercise.模块:import randomimport numpy as npimport scipy as spimport pandas as pd...

2018-06-11 20:41:52 220

原创 作业——Scipy

Scipy使用的模块:import numpy as npimport scipy.optimize as optimport scipy.spatial.distance as disExercise 10.1: Least squaresdef my_argmin(x, A, b): x = np.reshape(x, (10, 1)) return np.linalg.n...

2018-06-01 19:35:33 229

原创 作业——Matplotlib

MatplotlibExercise 11.1: Plotting a functionPlot the function        f(x) = [sin(x -2)]^2 *exp(-x)^2over the interval [0; 2]. Add proper axis labels, a title, etc.x = np.arange(-5, 5, 0.1)y = (np.sin...

2018-05-26 16:26:46 249

原创 作业——exercise

9 NumpyGenerate matrices A, with random Gaussian entries, B, a Toeplitz matrix, where A ∈Rn×m and B ∈Rm×m, for n = 200, m = 500.导入模块:import numpy as npimport timefrom scipy.linalg import toeplitz创建建...

2018-05-22 23:16:22 235

原创 第九周作业2

存在重复给定一个整数数组,判断是否存在重复元素。如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。示例 1:输入: [1,2,3,1]输出: true示例 2:输入: [1,2,3,4]输出: false示例 3:输入: [1,1,1,3,3,4,3,2,4,2]输出: truePython1class Solution(object):2 ...

2018-05-04 11:35:58 598

原创 第九周作业1

题目1旋转数组给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。示例 1:输入: [1,2,3,4,5,6,7] 和 k = 3输出: [5,6,7,1,2,3,4]解释:向右旋转 1 步: [7,1,2,3,4,5,6]向右旋转 2 步: [6,7,1,2,3,4,5]向右旋转 3 步: [5,6,7,1,2,3,4]示例 2:输入: [-1,-100,3,99]...

2018-04-29 22:37:56 226

原创 第八周作业

题目1:  从排序数组中删除重复项给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。示例 1:给定数组 nums = [1,1,2], 函数应该返回新的长度 2, 并且原数组 nums 的前两个元素被修改为 1, 2。 你不需要考虑数组中超出新长度后面的...

2018-04-29 21:11:46 107

原创 第十一章作业

"""11.1 城市和国家"""#city_functions.pydef city_country(city, country): result = city +", " + country return result#test_cities.pyimport unittestfrom chapter11 import city_countryclass CityTestCase(unittes...

2018-04-15 00:35:14 297

原创 第十章作业

"""10.1 Python学习笔记"""file_name = 'learning_python.txt'with open(file_name) as file_object: contents = file_object.read() print(contents.rstrip())with open(file_name) as file_object: for line in file_...

2018-04-07 17:25:27 334

原创 第十章作业

"""9.1 餐馆"""class Restaurant(): def __init__(self, name, _type): self.restaurant_name = name self.cuisine_type = _type def describe_restaurant(self): print("The name of the restaurant is: " + self...

2018-04-07 13:54:11 163

原创 第八章作业

"""8.1 消息"""def display_message(): print("I'm learning to use function.")display_message()"""8.2 喜欢的图书"""def favorite_book(title): print("One of my favorite books is " + title.

2018-03-31 11:21:59 430

原创 第七章作业

"""7.1 汽车租赁"""car = input("What kind of car do you want to borrow: ")print("Let me see if I can find you a " + car.title() + ".")"""7.2 餐馆订位"""total = input("How

2018-03-26 20:32:22 187

原创 第六章作业

"""6.1 人"""friend = {'first_name': 'LI', 'last_name': 'Xiaoming', 'age': 19, 'city': 'Guangzhou'}print(friend['first_name'] + ' ' + friend['last_name'])print(friend['age'])print(friend['city'])"""6.2 ...

2018-03-23 16:46:47 144

原创 第五章作业

"""5.1 条件测试"""fruit = 'apple'print("Is fruit == 'apple'? I predict True.")print(fruit == 'apple')print("Is fruit == 'pear'? I predict Fsldr.")print(fruit == 'pear')fruit = 'banana'print("\nIs fruit ==.

2018-03-20 11:29:48 170

原创 第三章作业

"""3.1 姓名"""names = ['Niki', 'Bob', 'Anddy']for item in names: print(item) """3.2 问候语"""names = ['Niki', 'Bob', 'Anddy']for item in names: print(item + ", how are you?") ""&quo

2018-03-14 21:47:33 236

原创 第四章作业

"""4.1 比萨"""pizza_names = ['thick pizza', 'pan pizza', 'pepperoni pizza']for pizza in pizza_names: print(pizza) print(pizza.title() + " is very delicious.")print("But I like " + pizza_names[2] + " mus.

2018-03-14 21:46:25 123

原创 假如是一个python编程高手

       python高手可以做什么?        从应用领域上讲,python“统治”的版块可以说是相当的广阔。虽然在我目前的“菜鸡阶段”,python只是被用来简单地解决一些小问题,但不意味着它的功能是很简单而狭小的。在系统编程方面、网络爬虫方面、人工智能科学计算方面、WEB开发、大数据云计算方面等等,python都有着广泛的应用。所以当如果我是一个python编程高手的时候,我问自己的...

2018-03-10 18:39:37 165

原创 浏览python主页之发现与收获

         在python网站主页上,首先给人的印象就是相当的整洁。入眼顶层可以看到分为Python、PSF、Docs、PyPI、Jobs、Community这几个大版块。在每个版块之中也分别有着细分的内容。在首页上,有这么一句话——Python is a rogramming language that lets you work quickly and integrate systems...

2018-03-09 16:05:19 203

原创 第二章作业

"""2.1 将一条消息存储到变量中,再将其打印出来"""message = "I want to learn well in python."print(message)"""2.2 将一条消息存储到变量中,再将其打印出来;再将变量的值修改为一条新消息,并将其打印出来"""message = "I want to learn well in python.&

2018-03-08 23:13:56 229

空空如也

空空如也

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

TA关注的人

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