zoukankan      html  css  js  c++  java
  • think python chapter3

    3.1 built-in function

         type(42)=> <class 'int'>

         int('32')=>32

         int(3.9) => 3

         int(-2.3)=>-2

         float(32)=> 32.0

         float('3.14159')=>3.14159

         str(32) => '32'

         str(3.14159)=>'3.14159'

    3.2 define a function

    Defining a function creates a function object, which has type function.

    you have to create a function before you can run it. In other words, the function definition has to run before the function gets called. 

    The rules for function names are the same as for variable names: letters, numbers and underscore are legal, but the first character can’t be a number.  

    Single quotes and double quotes do the same thing; most people use single quotes except in cases like this where a single quote (which is also an apostrophe) appears in the string. 

    Function definitions get executed just like other statements, but the effect is to create function objects. The statements inside the function do not run until the function is called, and the function definition generates no output. 

    3.3 flow of execution

    Execution always begins at the first statement of the program. Statements are run one at a time, in order from top to bottom.

    Function definitions do not alter the flow of execution of the program, but remember that statements inside the function don’t run until the function is called. 

    A function call is like a detour in the flow of execution. Instead of going to the next state- ment, the flow jumps to the body of the function, runs the statements there, and then comes back to pick up where it left off. 

    3.8 Variables and parameters are local
    When you create a variable inside a function, it is local, which means that it only exists inside the function. 

  • 相关阅读:
    【STM32】串行通信原理
    【STM32】NVIC中断优先级管理
    【Linux-驱动】RTC设备驱动架构
    【Linux-驱动】在sysfs下创建对应的class节点---class_create
    【Linux-驱动】将cdev加入到系统中去---cdev_add
    【Linux-驱动】简单字符设备驱动结构和初始化
    【Linux-驱动】printk的打印级别
    【Linux 网络编程】REUSADDR
    【Linux 网络编程】常用TCP/IP网络编程函数
    linux定时重启tomcat脚本
  • 原文地址:https://www.cnblogs.com/zxpo/p/5374594.html
Copyright © 2011-2022 走看看