摘要: def weight_converter(gram): total_weight = gram / 1000 return str(total_weight) + 'KG' the_weight = weight_converter(3000) print(the_weight) 阅读全文
posted @ 2017-07-16 22:34 mxyzptlk 阅读(192) 评论(0) 推荐(0)
摘要: # get sentence from user original = input('Please enter the sentence you want to translate: ').strip().lower() # split sentence to words words = original.split() # loop through words and translate to... 阅读全文
posted @ 2017-07-16 21:17 mxyzptlk 阅读(253) 评论(0) 推荐(0)
摘要: # 1 vowels = 0 consonants = 0 for letter in 'supercalifragilisticexpialidocious': if letter.lower() in 'aeiou': vowels = vowels + 1 elif letter == ' ': pass else: ... 阅读全文
posted @ 2017-07-16 17:01 mxyzptlk 阅读(110) 评论(0) 推荐(0)
摘要: from random import choice questions = ['Why is the sky blue? ', 'Why do cats have 4 legs? ', 'Why is the summer hot? '] question = choice(questions) answer = input(questi... 阅读全文
posted @ 2017-07-16 16:41 mxyzptlk 阅读(142) 评论(0) 推荐(0)