自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 Python语言程序设计Y.Daniel Liang练习题Chapter12

ckp12.1'''先把父类导入进来,再在自己定义的类里包含进这个类名super()可以继承父类的变量和方法super().__init__()'''ckp12.2class A: def __init__(self, i = 0): self.i = iclass B(A): def __init__(self, j = 1): super().__init__() self.j = jdef main()

2021-12-14 08:15:00 459 1

原创 Python语言程序设计Y.Daniel Liang练习题Chapter9.2

ckp9.21-9.23'''ckp9.21LEFT需要和side一块使用,LEFT是side的属性值,如果直接使用pack(LEFT)那么就会报错出现 AttributeError: 'str' object has no attribute 'items'ckp9.22THe Pack Managerckp9.23The place manager is not compatible with all computers. If you run this program onW

2021-12-08 14:15:00 297

原创 Python语言程序设计Y.Daniel Liang练习题Chapter9

ckp9.4-9.5'''ckp9.4window = Tk()ckp9.5callback functions handlers'''ckp9.6-9.11'''ckp9.6label = Label(window, text = "Welcome", fg = "white", bg = "red")ckp9.7button = Button(window, text = "OK", fg = "white", bg = "red", command = pro

2021-11-29 07:00:00 425 1

原创 Python语言程序设计Y.Daniel Liang练习题Chapter8

ckp8.1s1 = "Welcome to python"s2 = s1s3 = "Welcome to Python"s4 = "to"a = (s1 == s2)b = (s2.count('o'))c = (id(s1) == id(s2))d = (id(s1) == id(s3))e = (s1 <= s4)f = (s2 >= s4)g = (s1 != s4)h = (s1.upper())i = (s1.find(s4))j = (s1[4])

2021-11-24 12:17:41 997

原创 Python语言程序设计Y.Daniel Liang练习题Chapter7.2

list7.7_TeseLoanClass.pyfrom Loan import Loandef main(): # Enter yearly interest rate annualInterestRate = eval(input("Enter yearly interest rate, for example, 7.25: ")) # Enter number of years numberOfYears = eval(input("Enter number

2021-11-10 21:24:57 739

原创 Python语言程序设计Y.Daniel Liang练习题Chapter7

Circle.pyimport mathclass Circle: # Construct a circle object def __init__(self, radius = 1): self.radius = radius def getPerimeter(self): return 2 * self.radius * math.pi def getArea(self): return self.radius

2021-11-06 10:28:37 790

原创 遗传算法求函数的最值问题

一、遗传算法概述遗传算法(Genetic Algorithm,GA)最早是由美国的 John holland于20世纪70年代提出,该算法是根据大自然中生物体进化规律而设计提出的。是模拟达尔文生物进化论的自然选择和遗传学机理的生物进化过程的计算模型,是一种通过模拟自然进化过程搜索最优解的方法。该算法通过数学的方式,利用计算机仿真运算,将问题的求解过程转换成类似生物进化中的染色体基因的交叉、变异等过程。在求解较为复杂的组合优化问题时,相对一些常规的优化算法,通常能够较快地获得较好的优化结果。遗传算法已被人

2021-10-31 17:26:43 7799 1

原创 Python语言程序设计Y.Daniel Liang练习题Chapter6

sec6.1def getPentagonaNumber(n): m = n * (3 * n - 1) / 2 print(format(m, "8.0f"), end = '')k = 100for i in range(1, k + 1): getPentagonaNumber(i) if i % 10 == 0: print()sec6.2def sumDigits(n): x = 0 while n..

2021-10-29 19:58:41 799

原创 Python语言程序设计Y.Daniel Liang练习题Chapter5

ckp系列ckp5.3'''i = 1while i < 10: if i % 2 ==0: print(i)# 无穷次i = 1while i < 10: if i % 2 == 0: print(i) i += 1# 无穷次'''i = 1while i < 10: if i % 2 == 0: print(i) i += 1# 9次ckp5.4

2021-10-21 20:58:59 587

原创 Python语言程序设计Y.Daniel Liang练习题Chapter4

ckp4.1'''<小于<=不大于>大于>=不小于==等于!=不等于'''ckp4.2i = int(True)j = int(False)b1 = bool(4)b2 = bool(0)print(i, j, b1, b2)ckp4.3-4.6import random# output 0<=i<20i = int(random.random() * 20)print(i)# outpu...

2021-10-14 10:36:59 444

原创 Python语言程序设计Y.Daniel Liang练习题Chapter3

list3.1import mathprint("exp(1.0)=", math.exp(1))print("log(2.78)=", math.log(math.e))print("log10(10,10)=", math.log(10,10))print("sqrt(4.0)=", math.sqrt(4.0))print("sin(PI/2)=", math.sin(math.pi/2))print("cos(PI/2)=", math.cos(math.pi/2))prin

2021-09-30 11:54:36 563

原创 MATLAB的GUI小试牛刀

要实现一个这样的功能:点击单选框选择输出的图像,并且text的字也就是标题能随着按钮的切换来改变,比如点击的是“正弦曲线”,那么此时“图像”变成了“sin(x)”,并且在坐标里也会显示出正弦波形。“EXIT”按钮实现的是关闭程序的功能。效果图如下。首先打开GUI的界面,拖3个radiobutton、1个pushbutton、1个text、1个axes。 分别设置他们的属性,随你喜好。 分别对控件编译程序。 function GUI_1_OpeningFcn(hObject, event

2021-09-29 11:27:42 759

原创 Python语言程序设计Y.Daniel Liang练习题Chapter2

Section2.1Celsius=eval(input("Enter a degree in Celsius:"))Fahrenheit=(9/5)*Celsius+32print(Celsius, "Celsius is", Fahrenheit, "Fahrenheit")Section2.6num=eval(input("Enter a number between 0 and 1000:"))a=num%10b=(num//10)%10c=(num//10)//10.

2021-09-26 22:06:59 249

原创 Introduction to Programming Using Python练习题Chapter1

Section1.12import turtleturtle.penup()turtle.goto(-50, 50)turtle.pendown()turtle.goto(-50, -50)turtle.goto(50, -50)turtle.goto(50, 50)turtle.goto(-50, 50)turtle.penup()turtle.goto(-50, 0)turtle.pendown()turtle.goto(50,0)turtle.penup()turt

2021-09-23 16:03:49 422

空空如也

空空如也

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

TA关注的人

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