Learn Python 014: Funtions

def weight_converter(gram):
    total_weight = gram / 1000
    return str(total_weight) + ‘KG‘
the_weight = weight_converter(3000)
print(the_weight)
时间: 2024-10-11 21:38:01

Learn Python 014: Funtions的相关文章

Learn Python the Hard Way--Exercise 46

0. 缘起 <Learn Python the Hard Way>Exercise 46 要求安装四个python package pip, distribute, nose, virtualenv,(原书作者特别提醒: Do not just donwload these packages and install them by hand. Instead see how other people recommend you install these packages and use th

Learn Python From &#39;Head First Python&#39; [3](2) : Pickle

1.the use of 'with open... as ...' 2.the use of pickle(dump and load) for Step1: the 'with open ... as...' is the short format of 'try...except...finally' for Step2: you can store a list with pickle.dump() and get the content again with pickle.load()

Learn Python From &#39;Head First Python&#39; [2] : Sharing

1.publish 2.update print_lol PS: for Step 1. write the code in to a py file. put the py file into a folder named nester. new a py file named 'setup' and the content as below: setup( name = 'nester', version = '1.0.0', py_modules = ['nester'], author

Learn Python From &#39;Head First Python&#39; [1] : The List

1.the concept of List 2. how to define a method of myself 3.how to iterator a list PS: for Step 2,3. it is related with a key word: 'def'. we define a function like below. def function name: XXXXX e.g. list iterator : 1 def print_lol(the_list): 2 for

Learn Python From &#39;Head First Python&#39; [0] : Install

1. download software form the python‘s webset 2. install the python and set the class path 3. verify if the install is correct PS: for Step 2. if you use the default install. then undre the disk C:, there will be a dir like Python34. go to the env se

Learn Python From &#39;Head First Python&#39; [3] : Exception

1.the using of exception 2.file opration import os >>> try: data = open('sketch.txt') for each in data: try: (role,message) = each.split(':') print(role + ' says: ' + message, end='') except ValueError: pass data.close() except IOError: print('fi

How to learn Python

https://www.udemy.com/python-programming-for-real-life-networking-use/ https://pynet.twb-tech.com/blog/python/books-beginners.html Python Book Recommendations for Beginners (2014-01-17) By Kirk Byers You have decided to learn Python, but which Python

笨办法学 Python (Learn Python The Hard Way)

最近在看:笨办法学 Python (Learn Python The Hard Way) Contents: 译者前言 前言:笨办法更简单 习题 0: 准备工作 习题 1: 第一个程序 习题 2: 注释和井号 习题 3: 数字和数学计算 习题 4: 变量(variable)和命名 习题 5: 更多的变量和打印 习题 6: 字符串(string)和文本 习题 7: 更多打印 习题 8: 打印,打印 习题 9: 打印,打印,打印 习题 10: 那是什么? 习题 11: 提问 习题 12: 提示别人

[IT学习]Learn Python the Hard Way (Using Python 3)笨办法学Python3版本

黑客余弦先生在知道创宇的知道创宇研发技能表v3.1中提到了入门Python的一本好书<Learn Python the Hard Way(英文版链接)>.其中的代码全部是2.7版本. 如果你觉得英文版看着累,当当网有中文版,也有电子版可以选择. 我试着将其中的代码更新到Python 3.同时附上一些自己的初学体会,希望会对你有帮助. 中文版有人把书名翻译为<笨办法学python>,其实我觉得叫做<学Python,不走寻常路>更有意思些. 作者的意思你可以在序言中详细了解