![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
文章平均质量分 72
qq_27168139
这个作者很懒,什么都没留下…
展开
-
python 初体验,以及关于python项目的一些设想
这学期选了高级编程技术这门课程,其中所用到的编程语言就是python,所以应老师建议开设一个博客来记录python学习中的所学所思所感。 首先要做的事就是去访问官方文档库。此时也了解了python的一些特点。 1. 简单Python是一种代表简单思想的语言。 2. 易学Python有极其简单的语法。 3. 免费、开源Python是FLOSS(自由/开放源码软件)之一...原创 2018-03-11 19:15:25 · 290 阅读 · 0 评论 -
matplotlib
Exercise 11.1: Plotting a functionx = np.linspace(-2, 2, 1000)y = np.power((np.sin(x - 2)), 2) * np.exp(-x * x)plt.plot(x, y)plt.show()程序运行结果Exercise 11.2: DataX = np.random.randint(10, 20, (20, 10...原创 2018-06-28 16:41:05 · 190 阅读 · 0 评论 -
numPy
import numpy as npimport scipy.linalg as sl;# 9.1print("matrix operations\n");def addMat(A): return A+Adef multAAT(A): return A*A.Tdef multATA(A): return A.T*Adef multAB(A,B): ...原创 2018-06-19 18:22:16 · 232 阅读 · 0 评论 -
letCode Median of Two Sorted Arrays (#4)
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 = [1, 3]nums2 ...原创 2018-06-19 15:35:46 · 131 阅读 · 0 评论 -
letCode Merge K Sorted Lists (#23)
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5...原创 2018-06-19 15:34:20 · 109 阅读 · 0 评论 -
letCode Sort List (#148)
Sort a linked list in O(n log n) time using constant space complexity.解题思路:用归并排序的方法,因为表为链表,用快慢指针方法找到他的一半的位置,递归操作直到链表有序。代码如下:class ListNode: def __init__(self, x): self.val = x self...原创 2018-06-19 15:33:06 · 101 阅读 · 0 评论 -
leetCode#134 gas station
There are N gas stations along a circular route, where the amount of gas at station i isgas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel fromstation i to its nex...原创 2018-06-19 15:31:08 · 107 阅读 · 0 评论 -
python 文件和异常处理
#10-1 python学习笔记with open("learnpy.txt") as file_pro: contents = file_pro.read() print(contents)with open("learnpy.txt") as file_pro: for line in file_pro: print(line)with open("...原创 2018-04-23 09:29:24 · 706 阅读 · 0 评论 -
python 类
#9-1 餐馆 :创建一个名为 Restaurant 的类,其方法 __init__() 设置两个属性: restaurant_name 和 cuisine_type 。创建一个名#为 describe_restaurant() 的方法和一个名为 open_restaurant() 的方法,其中前者打印前述两项信息,而后者打印一条消息,指出餐馆正在营业。class Restaurant(): ...原创 2018-04-16 09:58:33 · 235 阅读 · 0 评论 -
python 方法
#8-2 喜欢的图书 :编写一个名为 favorite_book() 的函数,其中包含一个名为 title 的形参。这个函数打印一条消息,如 One of my favorite books is#Alice in Wonderland 。调用这个函数,并将一本图书的名称作为实参传递给它。def showBook(title): """显示喜欢的书籍""" print("my favorit...原创 2018-04-01 12:57:18 · 1606 阅读 · 0 评论 -
python input and while循环
#7-2 餐馆订位 :编写一个程序,询问用户有多少人用餐。如果超过 8 人,就打印一条消息,指出没有空桌;否则指出有空桌。dinnerNums = input("how many people will go to dinner?")if int(dinnerNums)>8: print("sorry, there is no enough disk")else: print('o...原创 2018-04-01 11:30:30 · 437 阅读 · 0 评论 -
python 字典
#6-1 人 :使用一个字典来存储一个熟人的信息,包括名、姓、年龄和居住的城市。该字典应包含键 first_name 、 last_name 、 age 和 city 。#将存储在该字典中的每项信息都打印出来。user_0 = {'first_name': 'han','last_name': "zheng" ,'age': 21 ,'city': 'gz'}print(user_0)pri...原创 2018-04-01 11:05:04 · 298 阅读 · 0 评论 -
python 列表以及其操作
#3-1 姓名: 将一些朋友的姓名存储在一个列表中,并将其命名为 names 。依次访问该列表中的每个元素,从而将每个朋友的姓名都打印出来。#3-2 问候语: 继续使用练习 3-1 中的列表,但不打印每个朋友的姓名,而为每人打印一条消息。每条消息都包含相同的问候语,但抬头为相应朋友的姓名。names = ['silly','b','fff']print(names)for name in ...原创 2018-03-18 19:00:02 · 428 阅读 · 0 评论 -
scipy
1.Generate matrix A belongs to Rm*n with m > n. Also generate some vector b belongs to Rm.Now x = arg min ||Ax -b||2Print the norm of the residualm = 20n = 10A = np.random.rand(m,n)b = np.random...原创 2018-06-28 17:44:49 · 130 阅读 · 0 评论