Python functions need to be constantly learned and improved

Source: Internet
Author: User

Python functions require constant learning of related technologies. Let's take a look at how to meet the current problems and solutions in practical applications. A comma tells the python function not to start a new line. Each python object has a position, a type, and a value.

Print "Hello", print "World"
 

For example, the following code is provided:

 
 
  1. input1=raw_input(“enter a number”)  
  2. input1=int(input1) 

When we execute the first line of the statement, the python function will first create an object with the content of the string "8" and place it in a memory location, then the value assignment operator binds input1 to the new object.

When the second statement is executed, python creates an object of int 8 again. After the value is assigned, python binds input1 to the newly created memory location, the position containing the string "8" is no longer referenced,

We can use the id () and type () functions to obtain the memory location and type of the variable, as shown below:

 
 
  1. print " input1:",id(input1),type(input1),int2 

Python function string

You can use one pair of single quotes, double quotes, three single quotes, and three double quotes to create a string.

Use "\" as the continue line symbol

  • Compile functions using Python Functions
  • How to define Python Functions
  • Deep Analysis of Python function programming skills
  • How to correctly use Python Functions
  • Sample Code for calling Python functions in C

Python Functions

The python function defines three namespaces: local, global, and built-in namespaces. The program searches for the values of identifiers in the local, global, and built-in order. The built-in naming contains many python functions and error message identifiers, such as raw_input and int. We can use the dir Module name of the built-in function to obtain the global identifiers, such as _ name __,__ doc _, which are defined by python itself.

We can use the from/import Statement to import one or more identifiers in the module to the namespace of the current program, such as from math import sin, cos, sqrt, after the import, we can directly use the import function without using it .) point.

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.