Python Learning (16) built-in functions, recursive

Source: Internet
Author: User

1. Recursion
 def   test1 (): num  =int (input ( "  Enter number  "   Span style= "color: #000000"))  if  num%2==0: #          return  True #   is even, program exits, returns true  print  ("   Not even please reenter   " )  return  Test1 () #   Not even then continue calling yourself, enter a value  print  (Test1 ()) 

Recursive efficiency is not high, the maximum recursion 999 times

2. Built-in functions

Python's own function

ID () #看内存地址
type () #看数据类型
print () #打印
input () #输入
list () #转list
set () #转集合
str () #转字符串
dict () #转字典
int () #转int
float () #转float
Len () #字符串长度
Print (All ([1,2,3,4])) #判断可迭代的对象里面的值是否都为真
print (Any ([0,1,2,3,4])) #判断可迭代的对象里面的值是否有一个为真
print (BIN) #十进制转二进制
Print (bool (' s ')) #把一个对象转换成布尔类型 (non-null-true, not 0-true)
print (CHR) #打印数字对应的ascii
Print (ord (' B ')) #打印字符串对应的ascii码

EXEC () #执行括号内的代码

d={}print (dir (d))# to print callable methods of incoming objects
A=eval ('1+2')print(a)  # executes Python code, only executes some simple code, such as arithmetic

Print (filter (lambda x:x>5,[12,3,12,2,1,2,35)) #把后面的迭代对象根据前面的方法筛选
Print (Map (lambda x:x>5,[1,2,3,4,5,6))
Print (max (111,12)) #取最大值
Print (Round (11.1123,2)) #取几位小数
Print (sorted ([2,31,34,6,1,23,4])) #排序

Python Learning (16) built-in functions, recursive

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.