Python function 01

Source: Internet
Author: User

# no parameters and returned functions def say_hi ():    print ("hi!") Say_hi () Say_hi () # has parameters, no return value Def print_sum_two (A, B):    C = a + b    print (c) Print_sum_two (3, 6) def hello_some (str):    print ("Hello" + str + "!") Hello_some ("China") hello_some ("Python") # has parameters, has return value def repeat_str (str, times):    repeated_strs = str *    times return repeated_strsrepeated_strings = Repeat_str ("Happy birthday!", 4) print (repeated_strings) # global variable with local variable x = 60def foo ( x):    print ("X is:" + str (x))    x = 3    print ("Change local x to" + str (x)) foo (x) print (' x is still ', str (x))

Output:

Hi! Hi!9hello China!hello python! Happy birthday! Happy birthday! Happy birthday! Happy birthday!x Is:60change Local x to 3x is still 60

  

Python function 01

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.