Python Numpy Tutorials: 函数

来源:互联网 发布:mac迅雷链接不合法 编辑:程序博客网 时间:2024/06/06 09:22

本文内容: 函数

# -*- coding: utf-8 -*-"""Python Version: 3.5Created on Mon May  8 21:01:40 2017E-mail: Eric2014_Lv@sjtu.edu.cn@author: DidiLv"""# function 1: def sign(x):    if x > 0:        return 'positive'    elif x < 0:        return 'negative'    else:        return 'zero'for x in [-1, 0, 1]:    print(sign(x))# Prints "negative", "zero", "positive"# function 2:def hello(name, loud=False):    if loud:        print('HELLO, %s!' % name.upper())    else:        print('Hello, %s' % name)hello('Bob') # Prints "Hello, Bob"hello('Fred', loud=True)  # Prints "HELLO, FRED!"
0 0
原创粉丝点击