Python基础编程(1)
LearningYard新学苑
分享兴趣,传播快乐,增长见闻,留下美好!
少年易老学难成,一寸光阴不可轻。
Python基础编程(1)
关于Python
Python由 荷兰数学和 计算机科学研究学会的 Guido van Rossum 于1990 年代初设计,作为一门叫做 ABC语言的替代品。Python提供了高效的高级 数据结构,还能简单有效地 面向对象编程。Python语法和动态类型,以及 解释型语言的本质,使它成为多数平台上写 脚本和快速开发应用的编程语言,随着版本的不断更新和语言新功能的添加,逐渐被用于独立的、 大型项目的开发。
Python强大的库函数
Python拥有一个庞大,且还在不断拓展的标准库。它可以帮助处理各种工作,包括 正则表达式、文档生成、 单元测试、 线程、数据库、网页浏览器、CGI、FTP、电子邮件、XML、XML-RPC、HTML、WAV文件、密码系统、GUI( 图形用户界面)、Tk和其他与系统有关的操作。这被称作Python的"功能齐全"理念。除了标准库以外,还有许多其他高质量的库,如wxPython、Twisted和Python图像库等等。
定义和调用函数
1、 位置参数
Python 的语法比较简单,采用缩进方式,写出来的代码就像下面的样子:
以#开头的语句是注释,注释是给人看的,可以是任意内容,解释器会忽略掉注释。其他每一行都是一个语句,当语句以冒号:结尾时,缩进的语句视为代码块。
在 Python 中,定义一个函数要使用 def 语句,依次写出函数名、括号、括号中的参数和冒号:,然后,在缩进块中编写函数体,函数的返回值用 return 语句返回。调用函数时根据函数定义的参数位置来传递参数,这样的参数被称为‘位置参数’。
2、 关键字参数
关键字参数允许你传入 0 个或任意个含参数名的参数,这些关键字参数在函数内部自动组装为一个 dict。在调用拥有关键字参数的函数时,可以只传入必选参数(name 和 age),也可以传入任意个数的关键字参数。
运行结果如下:
说明:
(1)定义一个 my_abs 函数,该函数的功能是传入一个位置参数,返回该参数的绝对值。然后调用该函数;
(2)定义一个 person 函数,该函数的功能是传入两个位置参数和一个关键字参数,在函数体内打印所有传入的参数。然后调用该函数两次,一次不带关键字参数,一次带关键字参数。
英文翻译
The English translation
Share interests, spread happiness, increase knowledge, leave beauty! Dear, this is LearningYard School. Today the editor brings you:
Python and its library functions——Pandas
About the Python
Python was designed in the early 1990s by Guido van Rossum of the Dutch Institute for Mathematical and Computer Science research as an alternative to a language called ABC. Python provides efficient high-level data structures, as well as simple and efficient object-oriented programming. Python syntax and dynamic typing, as well as the nature of the interpreted language, make it a programming language for scripting and rapid application development on most platforms. As versions continue to be updated and new features are added to the language, it is increasingly being used for independent, large project development.
Python"s powerful library functions
Python has a large and growing standard library. It can help with a variety of jobs, including regular expressions, document generation, unit testing, threading, databases, Web browsers, CGI, FTP, E-mail, XML, XML-RPC, HTML, WAV files, password systems, GUIs (graphical user interfaces), Tk, and other system-related operations. This is called Python"s "full-featured" idea. In addition to the standard library, there are many other high-quality libraries, such as the wxPython, Twisted, and Python image libraries, to name a few.
如果您对今天的文章有独特的想法,欢迎给我们留言。
让我们相约明天,祝您今天过得开心快乐!
本文由LearningYard学苑原创,
部分图片、视频素材来源网络,如侵权请沟通。
参考资料:
百度图片(图片)
百度百科(文字)