
python训练
超人琪
这个作者很懒,什么都没留下…
展开
-
非线性函数模型(多项式拟合)预测土壤侵蚀模数
某地区各地理单元的土壤侵蚀模数(x)与土壤含氮量1(y)的数据见(实验1数据中的“题目3”sheet)。画出二者之间的散点图并确定是什么样的相关形式; 试用一个非线性函数模型拟合该地区土壤侵蚀模数(x)与土壤含氮量(y)的关系; 检验该模型的显著性,并预测当土壤侵蚀模数x=8000t/(km2*a)时的土壤含氮量y。1. # coding=utf-8 2. import matplotlib.pyplot as plt 3. from matplotlib.font_manager.原创 2021-11-26 16:11:49 · 3492 阅读 · 0 评论 -
计算偏相关系数和复相关系数
根据4个要素的48个样本数据,计算得到的简单相关系数如下,试计算各级偏相关系数和复相关系数,并对其显著性进行检验。R=r11r12r13r14r21r22r23r24r31r32r33r34r41r42r43r44=10.99540.99040.99890.995410.99260.99230.99940.992610.99770.99890.99230.997711. import math 2. import numpy as np 3. import pandas as pd..原创 2021-11-26 15:52:12 · 8146 阅读 · 4 评论 -
计算相关系数进行显著性检验
某地区粮食产量与受灾面积的历年数据见(实验1数据中的“题目1”sheet),试计算二者之间的相关系数,并对相关系数进行显著性检验(α =0.05)1. import numpy as np 2. 3. x_simple=np.array([251,801,200,409,415,502,314,1101,980,1124]) 4. y_simple=np.array([52,101,65,88,90,98,120,150,140,120]) 5. 6. #计算相关系...原创 2021-11-26 15:39:12 · 8062 阅读 · 0 评论 -
python数据分析——文件操作
文件的打开>>> f1=open('d:\\infile.txt')//读入文件>>> f2=open(r'd:\outfile.txt','w')//写文件、清空文件内容或新建一个文件>>> f3=open('record.dat','wb',0)//a是追加//r+=r+w//w+=w+r/a+=a+r文件相关函数...原创 2021-11-26 15:32:33 · 336 阅读 · 0 评论 -
python程序调试与异常
# print(10/0)from ch4.TramError import TranErrortry: # print(10/0) a = b + 1 a = 1 + 1 b=3*2 a=int('abc') raise TranError(500001,'tranError')except (NameError,ZeroDivisionError) as e: print(type(e)) print(e)except Exc.原创 2021-08-17 21:14:24 · 103 阅读 · 0 评论 -
python——面向对象(继承)
import sys, ossys.path.append(os.path.dirname(os.path.abspath(__file__)))from p1 import Personclass Student(Person): def __init__(self,name,height,stno,school): super().__init__(name,height) #super为继承父类的属性 self.stno =stno .原创 2021-07-21 22:19:01 · 122 阅读 · 0 评论 -
python——面向对象(封装)
class Person: height=180 #类属性,是实例共享的,成员共享 name='王宝强' count=0 def __init__(self,name,height): #height是形参 # print('i am a person object') # return 'hehe' 必须返回的是空值 self.height=height #实例的属性,相当于person.heigh..原创 2021-07-21 22:12:00 · 99 阅读 · 0 评论 -
python——面向对象
# 面向对象OO# 类和对象# 属性和方法# 继承、封装、# class ClassDemo: #类名开头必须大写# '''类的一些说明'''# pass## '''类的使用——实例化一个类'''# myclass = ClassDemo()# myclass1 = ClassDemo()## print(myclass)#打印的是对象 <__main__.ClassDemo object at 0x000002D1A06B6AF0># print(m.原创 2021-07-20 21:51:29 · 104 阅读 · 0 评论 -
python函数调用参数
# 函数中的形参和实参def add(a,b): print("a=",a) print("b=",b) result= a+b return resultc=add(3,1)#必要参数A=add(b=3,a=1) #关键字参数c=add(1)#默认值参数print(c)def print_userinfo(name,gender,age,depart): print("我是:"+name) print("我是 "+gender+"生").原创 2021-07-19 17:19:08 · 1629 阅读 · 0 评论 -
python——建立函数
#内置函数 自定义函数# print('hello python')# round(1.12389,2)精确到小数点后2位# 内置函数# 1封装性,隐藏代码的细节# 2避免重复代码# 3函数都有一定的功能# 自定义函数# def funcname(paran s):# pass# 1定义一个打印hello字符串的方法# 2定义一个打印指定字符串的方法# 3定义一个计算加法的函数a+b# def Print(s):# print(s)# ms='he.原创 2021-07-19 16:12:53 · 628 阅读 · 1 评论 -
python语法学习六——异常
try-except语句>>> try: num1=int(input('1:')) num2=int(input('2:')) print(num1/num2)except ValueError: print('digit:')>>> try: num1=int(input('1:')) num2=int(input('2:')) p...原创 2020-04-01 22:56:03 · 187 阅读 · 0 评论 -
python语法学习五——函数库
math库>>> import math>>> dir(math)['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysi...原创 2020-04-01 22:34:54 · 222 阅读 · 0 评论 -
python语法学习四——函数
break语句>>> i=1>>> while i%3: print(i,end='') if i>=10: break i+=1 12continue语句自定义函数#输出素数from math import sqrtdef isprime(x): if x == 1: return F...原创 2020-04-01 22:09:24 · 220 阅读 · 0 评论 -
python语法学习三——循环
while循环#语法while expression: suite_to_repeat#代码>>> sum=0>>> j=1>>> while(j<10): sum+=j j+=1>>> sum45>>> j10for循环#语法for iter_var i...原创 2020-03-29 22:32:26 · 602 阅读 · 0 评论 -
python语法学习二——条件结构
if语句#结构,if表达式后必须要有冒号:必须要缩进if expression: expr_true_suite#代码sd1=3sd2=3if(sd2==sd2): print(sd1*sd2)else语句#结构,if,else表达式后必须要有冒号:必须要缩进if expression: expr_true_suiteelse: ex...原创 2020-03-29 21:17:10 · 433 阅读 · 0 评论 -
python语法学习一
终于要学python啦,我的笔记是基于python3.6,看的课程是南京大学张莉老师的"用python玩转数据"。首先呢,我是一名python小白,C语言基础一般般,学好python,将会是我人生中最值得骄傲的事情。1.python执行方式直接在shell中,短小的代码新建py文件,较多的代码2.语法基本1.标识符1)首字母是字母或下划线2)其余可以时字母、下划...原创 2020-03-27 23:30:34 · 236 阅读 · 0 评论