当前位置:网站首页>Self taught neural network series - 1 Basic programming knowledge
Self taught neural network series - 1 Basic programming knowledge
2022-06-26 09:09:00 【ML_ python_ get√】
python Basic knowledge of
1.1 Variable type
- integer 、 character string 、 floating-point
- list 、 Dictionaries 、 Tuples 、 Boolean type
print(type(10))
print(type(str(10)))
print(type(float(10)))
# Definition of variables 、 Calculation 、 assignment
# stay python Can be operated directly in , You can also assign values to variables to perform operations on variables
a = 10
print(a)
a = 100
print(a)
b = 3.14
print(a*b)
# python Dynamic language , The type of variable will change automatically according to the situation
# list
a = [1,2,3,4,5]
len(a)
# Indexes
a[0]
# assignment
a[4]=100
print(a)
# section
a[1:]
a[:-1]
a[:-2] # The slice does not contain : The next element
# Dictionaries
me = {
'height': 180}
# Indexes
me['height']
# assignment
me['height'] =100
me
# Add key value
me['weight'] = 70
me
# Boolean type
# The value is True /False A variable of
hungry = True # I'm hungry
sleepy = False # Not sleepy
type(hungry)
# operation Can only be and or not
not hungry
hungry and sleepy
hungry or sleepy
hungry = True
if hungry:
print("I'm hungry!")
hungry = False
if hungry:
print("I'm hungry !")
else:
print("I'm not hungry!")
print("I'm sleepy!")
for i in [1,2,3]:
print(i)
# function
def hello():
print("hello world!")
hello()
# Function passed in parameters
def hello(object):
print("hello "+ object +'!')
hello("cat")
# class
class Man:
def __init__(self,name):
self.name = name
print("Initialized!")
def hello(self):
print("Hello " + self.name + "!")
def goodbye(self):
print("Goodbye " + self.name + "!")
def main():
m = Man("Wang")
m.hello()
m.goodbye()
if __name__== "__main__":
main()
# Array
# take X Turn into 1 Is an array
import numpy as np
x = np.array([[1,2],[3,4]])
x
x.flatten()
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(0,6,0.1) #60 Number
y1 = np.sin(x)
y2 = np.cos(x)
plt.plot(x,y1,label="sin")
plt.plot(x,y2,linestyle="--",label='cos')
plt.xlabel("x")
plt.ylabel('y')
plt.title("sin & cos") # title
plt.legend() # legend
plt.show()
# Read image imread And display images imshow
from matplotlib.image import imread
img = imread(" cover .jpg")
plt.imshow(img)
plt.show()
边栏推荐
- 关于小程序tabbar不支持传参的处理办法
- 运行时端的执行流程
- 1.21 study logistic regression and regularization
- Phpcms applet interface new universal interface get_ diy. php
- MySQL在服务里找不到(未卸载)
- [program compilation and pretreatment]
- phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)
- Phpcms applet plug-in version 4.0 was officially launched
- How to handle the small program tabbar that does not support parameter transfer
- phpcms v9后台增加阅读量字段,可任意修改阅读量
猜你喜欢

Games104 Lecture 12 游戏引擎中的粒子和声效系统

【C】青蛙跳台阶和汉诺塔问题(递归)

Isinstance() function usage

Yolov5 advanced camera real-time acquisition and recognition

Fix the problem that the rich text component of the applet does not support the properties of video cover, autoplay, controls, etc

phpcms手机站模块实现自定义伪静态设置

Phpcms V9 background article list adds one click push to Baidu function

Yolov5进阶之四训练自己的数据集

直播回顾 | smardaten李鸿飞解读中国低/无代码行业研究报告:风向变了

SRv6----IS-IS扩展
随机推荐
isinstance()函数用法
教程1:Hello Behaviac
[qnx hypervisor 2.2 user manual]12.1 terminology (I)
2021 software university ranking crawler program
phpcms小程序插件4.0版正式上线
The solution of positioning failure caused by framework jump
行为树XML文件 热加载
行为树 文件说明
Phpcms V9 adds the reading amount field in the background, and the reading amount can be modified at will
phpcms小程序插件api接口升级到4.3(新增批量获取接口、搜索接口等)
Phpcms applet interface new universal interface get_ diy. php
Graduation thesis management system based on SSM
1.23 neural network
Yolov5 advanced level 2 installation of labelimg
Uniapp uses uparse to parse the content of the background rich text editor and modify the uparse style
XSS 跨站脚本攻击
运行时端常用类的介绍
How to convert wechat applet into Baidu applet
Yolov5 advanced III training environment
phpcms v9手机访问电脑站一对一跳转对应手机站页面插件