python 英语教学中应用,python基础教程英文版

【Python・统计学】Mann-Whitney U检验/Wilcoxon秩和检验(原理及代码) 自学笔记,分享给对统计学原理不太清楚但需要在论文中用到的小伙伴,欢迎大佬们补充或绕道。ps:本文不涉及公式讲解(文科生小白友好体质)~(部分定义等来源于知乎百度等) 本文重点:Mann-Whitney U检验(也称Wilcoxon秩和检验) 【1.定义和相关背景】 【2.应用条件】 【3.数据实例以及Python代码】 阅读详情

大家好,小编为大家解答python 英语教学中应用的问题。很多人还不知道python基础教程英文版,现在让我们一起来看看吧!

Source code download: 本文相关源码

Learn python in a short time

1. Properties

Python is strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you
don’t have to declare variables), case sensitive (i.e. var and VAR are different variables) and
object-oriented (i.e. everything is an object).

2. Getting help

Help in Python is always available right in the interpreter. If you want to know how an object
works, all you need to do is to call help()! Also dir() are useful, which shows you all the
object’s methods and .doc.

# show the usage of the object 'int'
help(int)
#help(1)
# show the methods of int
dir(int)
# show the documents of

3. Syntax

Comments start with the pound (#) sign and are single-line. Values are assigned (in fact, objects
are bound to names) with the equals sign (”=”), and equality testing is done using two equals
signs (”==“). You can increment/decrement values using the += and -= operators respectively
by the right-hand amount. This works on many datatypes, strings included. You can also use
multiple variables on one line. For example:

# assign a value to variable
x = 1
# x = x + 2
x += 2
print(x)
# x = x - 1
x -= 1
print(x)
# concatenate two string by '+'
y = 'Hello '
y1 = 'world'
print(y + y1)
# Assign two values to two variable respectively
z1, z2 = 1, 'str'
print(z1, z2)
'''
swap z1 and z2
temp = z1
z1 = z2
z2 = temp
'''
z1, z2 = z2, z1
print(z1, z2)

4. Data types

The data structures available in python are lists, tuples and dictionaries. The index of the
first item in all array types is 0. Negative numbers count from the end towards the beginning, -1
is the last item. Variables can point to functions. The usage is as follows:

# list is a bit like array we have learned in c or c++
list_sample = [1,2]
print(list_sample)
list_sample1 = ['hello', 'world']
print(list_sample1)

# tuple is a bit like list,but its element can't be changed
tuple_sample = (1, 2, 3)
print(tuple_sample)
tuple_sample1 = ('hello', 'world')
print(tuple_sample1)
# try to change the element of tuple
tuple_sample1[0] = 'hey'
print(tuple_sample1)

# dictionnary = {key:value}
dict_sample = {'key1': 'value1', 2:3, 'tuple': (1,2)}
# get value by key
print(dict_sample['key1'])
print(dict_sample['tuple'][0])

# a list can contain any type of data
mix_sample = [5, 'hello world', [1, 'alex', (1,2,3)],('my', 'tuple')]
print(mix_sample[0])
#index -1 refers the last element
print(mix_sample[-1])
'''
variables point to functions
type() is a built-in function
help(type)
'''

function_sample = type
# show the type of list_sample
print(function_sample(list_sample))
# equivalent to the above line
print(type(list_sample))

list_sample2 = [1, 'a', 2, 'b', 3, 'c']
# only access the first element
first, *_ = list_sample2
print(first)
# only access the last element
*_, last = list_sample2
print(last)
#only access the second element
_, second, *_ = list_sample2
print(second)
# You can access array ranges using a colon (:). Leaving the start index empty assumes the first item, leaving the end index assumes the last item. Negative indexes count from the last item backwards (thus -1 is the last item) like so:4

# access values using index
list1 = [1, 2, 3, 4, 5, 6]
# array[start:end] access elements from start to end but not contain end
# access all elements
print(list1[:])
# access elements from zeroth to fifth
print(list1[0: 6])
print(list1[0: 2])
print(list1[-3:-1])

5. Strings

Python’s strings can use either single or double quotation marks, and you can have
quotation marks of one kind inside a string that uses the other kind (i.e. “He said ‘hello’.” is
valid). Multiline strings are enclosed in triple double (or single) quotes (”“”). To fill a string
with values, you use the % (modulo) operator and a tuple. Each %s gets replaced with an item
from the tuple, left to right, and you can also use dictionary substitutions, like so:

# %s will be replaced by variable in %()
print('Name: %s' % ('alex'))

# another usage
print('Name: %(name)s' % {'name':'alex'})

# {} will be replaced by parameters in .format()
print('Name: {}'.format('alex'))

#print a multi-line string
multi_string = '''this is a
multiline
string'''
print(multi_string)

print('Name: %s\nNumber: %d\nString: %s\n' % ('alex', 1, 4 * '-'))
print('this %(value1)s a %(value2)s\n' % {'value2':'test', 'value1':'is'})

message = 'let\'s learn {} in a {}'.format('python','short time')
print(message)

6. Flow control statements

Flow control statements are if, for, and while. Python has no mandatory statement
termination characters and blocks are specified by indentation. Indent to begin a block,
cancel indentation to end one. Statements that expect an indentation level end in a colon (?. These statements’ syntax is thus:

# generate a list which has elements from zero to nine
range_list = range(10)

'''
it will be written if we use c or c++
for(i=0; i <10; i++){
range_list[i] = i;
}
'''
print(range_list)
for i in range_list:
print(i,end=' ')

# format of the for loop

# for variable_name in iterable_object:

for number in range_list:
# Check if number is one of
# the numbers in the tuple.
    if number in (3, 4, 7, 9):
        # "Break" terminates a for without
        # executing the "else" clause.
        break
    else:
        # "Continue" starts the next iteration
        # of the loop. It's rather useless here,
        # as it's the last statement of the loop.
        continue
else:
    # The "else" clause is optional and is
    # executed only if the loop didn't "break".
    pass # Do nothing


if range_list[1] == 2:
	print("The second item (lists are 0-based) is 2")
elif range_list[1] == 3:
	print("The second item (lists are 0-based) is 3")
else:
	print("\nDunno")

# Format of the while loop
while range_list[0] == 1:
	pass

# add odd and even respectively
odd = 0
even = 0
for number in range(100):
	if number % 2 == 0:
		even += number
	else:
		odd += number
print('the total of odd:',odd)
print('the total of even',even)

7. Functions

Functions are declared with the def keyword. Optional arguments are set in the function declaration after the mandatory arguments by being assigned a default value. For named arguments, the name of the argument is assigned a value. Functions can return a tuple (and using tuple unpacking you can effectively return multiple values).Lambda functions are ad hoc functions that are comprised of a single statement. Parameters are passed by reference, but immutable types (tuples, ints, strings, etc)cannot be changed. This is because only the memory location of the item is passed, and binding another object to a variable discards the old one, so immutable types are replaced. For example:`

'''
Comment the function
def function_name(args):
\'''
coments
\'''
pass
'''
def passing_example(a_list, an_int = 2, a_string =" A default string"):
'''a_list: 
an_int: 
a_string: 
'''
a_list.append("A new item")
an_int = 4
return a_list, an_int, a_string

list1 = [0,1,2]
int1 = 10
print(passing_example(list1,int1))
#show method usage
help(passing_example)
# list1 will be changed
print(list1)
# int1 will not be changed
print(int1)

#swap function
a, b =1, 2
def swap(a,b):
t = a
a = b
b = t
return a, b

a, b = swap(a,b)
print(a,b)

#keyword parameter,its order is not important
def print_info(name, age=35):
print('name:',name,'age:',age)
print_info(age=50,name='miko')

#indefinite length parameter
#you may need a function that can handle more parameters than when you declared it.
def print_info(arg1, *args):
    print(arg1, end=' ')
    for x in args:
        print(x, end=' ')
        print('')

# pass one parameter
print_info(10)
# pass two parameter
print_info(10,20)
# pass three parameter
print_info(10,20,30)

#global variable and local variable
total = 0
def sum1(arg1, arg2):
total = arg1 +arg2
print(total)
def sum2(arg1, arg2):

# refer global variable
global total
total = arg1 + arg2
print(total)

sum1(10,20)
# total will not be changed
print(total)

sum2(10,20)
# total will be changed
print(total)

#anonymous function
# the same as def function(x): return x+1
functionvar = lambda x: x + 1 #lambda [arg1 [,arg2,.....argn]]:expression
print(functionvar(1))

8. Classes

Python supports a limited form of multiple inheritance in classes. Private variables and
methods can be declared (by convention, this is not enforced by the language) by adding at least two leading underscores and at most one trailing one (e.g. “spam”). We can also bind arbitrary names to class instances. An example follows:

Declaring a simple class
class People:
"""
Base class. It has two attributes: name and age,
and two methods: get_name and get_age to obtain attribute value.
When declaring classes, you must rewrite __init__ method to initialize class for most time
"""
    def __init__(self, name, age):
        """initialization"""
        # initialization for class's attribute, use self.xx
        self.name = name
        # initialization for class's attribute, use self.xx
    	self.age = age
        
    def get_age(self):
        # return self.age's value
        return self.age
	
    def get_name(self):
		# return self.name's value
		return self.name

# Obtain a People object and use its method
people = People(name='xiaoming', age=21) # obtain a People object
print(people)

# using class's method to get its attribute value
print('age :', people.get_age())
print('name :', people.get_name())

# directly get its value by access its attribute
print('age :', people.age)
print('name :', people.name)

# Declaring a class to inherit People class
class Student(People):
"""
Student inherit People class.
Thus, Student also have attribute like name and methods like get_age and get_name, get_.
In student class, we add one more attribute idx for student class, as well as a new method get_idx
"""
	def __init__(self,name, age, idx):
        # initialize name and age using People's initialization's method
        super(Student,self).__init__(name, age)
        # initialization for class's attribute
        self.idx = idx
    def get_idx(self):
        """
        add a new method for Student to obtain idx
        """
        return self.idx

# Obtain a Student object and use its method
student = Student('xiaoming', 21, 12)
print(student)
# using class's method to get its attribute value
print('age :', student.get_age())
print('name :', student.get_name())
# new method only owned by Student class
print('idx :', student.get_idx())
# directly get its value by access its attribute
print('age :', student.age)
print('name :', student.name)
print('idx :', student.idx)

9. File I/O

We could use open to open a file and do some complex operation like, opening for reading only,
opening with text mode. You can see more about open in python open’s method document. Here,
we just introduce open about its writing mode and reading mode.

# Writing a file
# 'w' => writing mode
# if there is no file named 'example.txt', it would be created and we could write something
# if there is a file called 'example.txt', its content would be erased and we could write something
# open(rootpath, mode), see more from document

with open("./example.txt",'w') as f:
# write 'hello world!' to files first line
f.writelines('hello world!')
# write 'Bye bye!' to files second line
f.writelines('Bye bye!')

# Reading a file, must exists first
# 'r' => reading only mode
with open('./example.txt','r') as f:
print(f.readlines()) # read all content at one time

10.Miscellaneous

list1 = [1, 2, 3]
list2 = [3, 4, 5]
# Calculate the product of any elements from list1 and list2

# [1*3,1*4,1*5,2*3,2*4,2*5,3*3,3*4,3*5]
print([x * y for x in list1 for y in list2])

# Select elements > 1 and < 4 for list1
# [2,3]
print([x for x in list1 if 1 < x < 4])

# if there exists a element that could be divided exactly by 3, return true
# True
print(any(i % 3 for i in range(10)))

# account how many 4 in a list
print(sum(1 for i in [2,2,3,3,4,4] if i == 4))
Ambari 安装部署教程(手把手教学)【超级详细】 本文为读者提供了一套超详细的 Apache Ambari 安装部署教程,采用手把手教学方式,适合初学者及大数据运维人员。内容涵盖前期准备、环境配置、Ambari Server 与 Agent 安装、集群初始化配置、常见问题排查等全流程操作,确保用户能够顺利搭建稳定的 Hadoop 大数据平台管理系统。 阅读详情

相关推荐

Unity性能优化 - 动态图集

Unity 动态图集是 Unity 引擎中用于处理游戏纹理优化的一种技术。本文介绍了什么是动态图集,动态图集的优缺点,以及提供了一套完整的代码供大家参考。

qq_33808037的博客 4840

基于python实现英语学习系统(附完整代码)

基于python实现英语学习系统(附完整代码)

1492

Camera Sensor接口协议全解析(六)聚焦onsemi HiSPi接口的技术突破与应用实践

摘要: Onsemi HiSPi是一种高速并行接口协议,专为高分辨率图像传感器设计,具备1600 Mbps传输速率、低功耗和高兼容性特点。通过对比DVP、MIPI CSI-2等主流协议,HiSPi在工业/医疗领域表现突出,支持动态功耗控制、多ROI和CRC校验。其创新架构包含多PHY设计,提供分组SP、流SP等多种工作模式,满足灵活传输需求。实际应用中,HiSPi在PCB缺陷检测(5μm精度)和液晶面板检测(0.3% Mura检出率)等场景展现卓越性能,成为高速成像领域的关键技术。

GateWorld的博客 1437

python 英语教学_用Python来学外语

缘起看到有人在简书里面谈起从事兼职的事情,忽然之间就觉得自己不能放下曾经学过的知识,特别是目前不常用的语言——英语。和中文一样,常用的字词应该是不多的,而本身,我又对编程略感兴趣,所以,看编程文档学英语结合起来,其实也是不错的,兴趣是学习的动力嘛。障碍太久没有看英语,很多单词啃不动,所以,需要借助工具来帮忙。环境介绍Windows XP Professional 32位 + Python2.7.x...

weixin_39882870的博客 405

无人驾驶之车辆控制(1)纯跟踪(Pure Pursuit)算法与Stanley算法

目录引言1 Pure Pursuit纯几何跟踪算法1.1 车辆运动学自行车模型1.2 算法原理1.3 仿真测试2 Stanley算法2.1 算法原理2.2 仿真测试3 总结 引言 本文对Pure Pursuit以及Stanley control两种算法进行了调研以及初步的性能摸底。 1 Pure Pursuit纯几何跟踪算法 1.1 车辆运动学自行车模型 运动学是从几何学的角度研究物体的运动规律,...

zxxxxxxy的博客 2万+

Windows 11登录界面密码框消失Bug解析与解决方案

Windows操作系统登录认证机制是系统安全的第一道防线,其图形界面由桌面窗口管理器(DWM)负责渲染。当UI元素渲染异常时,会导致密码输入框等关键组件不可见。这类图形子系统故障通常源于驱动兼容性或主题服务冲突,在Windows 11最新累积更新后尤为常见。通过系统文件检查(sfc)、注册表修复或创建新用户等工程实践方法可有效解决问题。对于企业IT环境,建议采用PIN码或生物识别等替代认证方案,同时定期执行磁盘清理和系统健康检查等Windows维护操作,确保认证服务稳定运行。

weixin_33806859的博客 630

Python在线学习系统

该在线学习系统的开发和设计根据用户的实际情况出发,对系统的需求进行了详细的分析,然后进行系统的整体设计,最后通过测试使得系统设计的更加完整,可以实现系统中所有的功能,在开始编写论文之前亲自到图书馆借阅 Dango框架书籍,MYSQL数据库书籍等编程书籍,然后针对开发的在线学习系统,去网上查找了很多别人做好的系统,参照他们的设计结果,来对自己的系统进行更加详细的系统的设计,将系统中所有的功能结果一一列举出来,然后进行需求分析,最后对所有的功能模块进行编码,最后完成系统的整体测试,实现系统的正常运行[6]。

qq_1406299528的博客 1375

复合材料成型仿真案例大全|覆盖模压 / RTM / 固化 / SMC,实操步骤直接抄

本文整理了一套完整的PAM-COMPOSITE复合材料成型仿真案例合集,涵盖模压、RTM、固化变形、SMC四大核心工艺,包含6个实操案例和1个全流程衔接案例。每个案例都配有详细的操作步骤、核心要点和缺陷排查方法,适用于不同水平的工程师和研究人员。案例内容源自实际项目,可直接复用,帮助用户快速掌握复合材料成型仿真的关键技术,解决褶皱、纤维堆积、气泡残留等常见问题,实现从铺层设计到强度校核的全流程仿真闭环。特别针对热固性/热塑性材料差异、RTM衍生工艺、链式仿真等难点提供了专项解决方案。

源代码杀手的博客 321

python 英语教学_Python基础教程(英文视频教学)

Python基础教程-.1.-.Installing_Python_video.flv: http://www.t00y.com/file/10034879-.2.-.Numbers_and_Math_video.flv: http://www.t00y.com/file/10034880-.4.-.Modules_and_Functions_video.flv: http://www.t00y....

weixin_39968490的博客 189

YOLOv8与UNetV2融合:一种面向目标检测与图像分割的混合方法【附核心代码】

我们提出了一种基于YOLOv8和UNetV2相结合的混合架构。该架构利用YOLOv8作为主干进行目标检测,同时在YOLOv8的特征提取过程中,引入UNetV2来进行图像分割任务的增强。在该架构中,YOLOv8负责大范围目标检测和位置预测,而UNetV2则在检测网络的特征图基础上,通过其高效的上下文信息提取和细节恢复能力,进一步优化分割任务。在本文中,我们提出了一种改进YOLOv8的方法,通过引入图像分割网络UNetV2来提高图像分割检测性能。

一键难忘的博客 3526

04 Zabbix自定义触发器

1、触发器是什么 触发器表达式:允许定义一个什么状况的数据是“可接受”的阈值。因此,如果接收的数据超过了可接受的状态,则触发器会被触发 , 或将状态更改为异常。 一个触发器可以拥有下面几种状态: 值 描述 OK 这是一个正常的触发器状态。在旧版本的Zabbix中称为FALSE。 PROBLEM 通常意味着发生了某些事情。例如,处理器的负载较高。在旧版本的Zabbix中称为TRUE。 2、创建触发器TRIGGER 案例:系统超过3个用户登录,则告警。 2.1 开启告警声

Jian Sun_的博客 1541

Python开发英语教学软件:Tkinter与pyttsx3实战

Python作为一门通用编程语言,在GUI开发和语音处理领域有着广泛应用。通过Tkinter框架可以快速构建跨平台图形界面,而pyttsx3库则提供了便捷的文本转语音功能。这些技术的组合特别适合开发教育类软件,能够实现单词展示、发音朗读等核心功能。本项目采用轻量级的JSON和CSV作为数据存储方案,降低了学习门槛,同时涵盖了Python文件操作、事件处理等基础知识点。对于初学者而言,这种将基础语法与GUI开发、语音处理相结合的实践方式,能够有效提升编程兴趣和实战能力。英语教学软件案例展示了如何用Python

weixin_30516429的博客 154

华为OD机试真题 新系统2026-04-08 Python&JS 实现【直捣黄龙】

小王在玩一款叫做直捣黄龙的小游戏,在该游戏中他需要从入口位置进入敌营,绕过哨兵的层层封锁,达到敌军司令部实施斩首行动。 敌军阵营是一个n*n的矩阵,入口在坐标(0,n/2),敌军司令部在坐标(n-1,n/2),每个哨兵警戒以自己为中心的9宫格,一旦被哨兵发现则行动失败。

MISAYAONE的博客 594

零基础:100个小案例玩转Python软件开发!第六节:英语教学软件

在这一节里,我们学习了导航栏工具条的使用,也掌握了如何使用pyttsx3进行语音播放和打包MSI。学会这些之后,你将可以制作一些语音类小工具。

红孩儿的游戏编程之路 948

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

上一篇: 文心一言能写作吗 PaperGPT
下一篇: python根据url下载大量图片,python通过链接下载文件
普通网友
博客等级 码龄22年 1万+粉丝 3156原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值