import pandas as pd def getEmpDataFrame(num): '''创建一份可复用的数据,有一定的随机性和真实...
''' http://pandas.pydata.org/pandas-docs/stable/10min.html numpy的主要数据结构是nda...
程序分析:演示一个python作用域使用方法。...#python3.7 class Num: nNum = 1 def inc(self): self.nNum += 1 print('nNum = %...#python3.7 X = [[12, 7, 3], [4, 5, 6], [7, 8, 9]] Y = [[5, 8, 1], [6, 7, 3], [4...#python3.7 TRUE = 1 FALSE = 0 def SQ(x): return x * x print('如果输入的数字小于50,程序将停止运行。')...#python3.7 def exchange(a, b): a, b = b, a return(a, b) if __name__ == '__main__': x =
#python 3.7 if __name__ == '__main__': N = 10 print('请输入10个数字:\n') l = [] print...#python 3.7 if __name__ == '__main__': a = [] sum = 0.0 for i in range(3): a.append...#python 3.7 if __name__ == '__main__': #加入0作为占位符 a = [1, 4, 6, 9, 13, 16, 19, 28, 40, 100, 0...#python 3.7 if __name__ == '__main__': a = [9, 6, 5, 4, 1] N = len(a) print(a) for i...1 for i in range(3): print('The num = %d' % num) num += 1 autofunc() 参考资料: Python 100例
times and 's' occurs twice "aA11" -> 2 # 'a' and '1' "ABBA" -> 2 # 'A' and 'B' each occur twice 首先可以利用Python
#python3.7 from sys import stdout if __name__ == '__main__': a = [] for i in range(10):...#python3.7 sStr1 = 'language' sStr2 = 'age' print(sStr1.find(sStr2)) 结果: 5 63、使用Tkinter画椭圆。...#python3.7 from tkinter import * if __name__ == '__main__': x = 360 y = 160 top = y - 30...#python3.7 from tkinter import * if __name__ == '__main__': canvas = Canvas(width = 400, height...#python3.7 if __name__ == '__main__': n1 = int(input('n1 = \n')) n2 = int(input('n2 = \n'))
程序分析:请参照程序Python 100例中的第14个例子 #python3.7 from sys import stdout for j in range(2, 1001): k = []...#python3.7 tour = [] height = [] sheight = 100.0#起始高度 tim = 10#次数 for i in range(1, tim + 1): if...#python3.7 x2 = 1 for day in range(9, 0, -1): x1 = (x2 + 1) * 2 x2 = x1 print(x1) 22、两个乒乓球队进行比赛...#python3.7 a = 2.0 b = 1.0 s = 0 for n in range(1,21): s += a / b t = a a = a + b b...= t print(s) 参考资料: Python 100例:http://www.runoob.com/python/python-100-examples.html
#python3.7 #适用于简单列表(即列表中都是基本的元素) a1 = [1,2] b1 = a1[:] print(b1) #不适合列表中包含列表的情况,如果要复制的列表中包含列表,只会复制那个列表的列表的引用...#python3.7 #左下三角格式输出九九乘法表 for i in range(1,10): for j in range(1,i+1): print('%d*%d=%d' %...#python3.7 import time #输出当前时间 print(time.strftime('%Y-%M-%D %H:%M:%S', time.localtime(time.time())...#python3.7 f1 = 1 f2 = 2 for i in range(1,22): print('%121d %121d' % (f1, f2)) if (i % 3) ==...100例:http://www.runoob.com/python/python-100-examples.html 2、将一个列表的数据复制到另一个列表中。
return ''.join(map(str,nums)) print(create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0])) 细心的小伙伴会发现Python...的函数很多,所以我们平时在刷题时,用什么函数需要根据题目要去考虑,然后最好把使用的函数记下来,到最后你会发现,Python的本质是灵活运用函数处理实际问题。
#python3.7 def inp(numbers): for i in range(6): numbers.append(int(input('输入一个数字:\n')))...#python3.7 if __name__ == '__main__': n = int(input('整数n为:\n')) m = int(input('向后移m个位置为:\n')...#python3.7 if __name__ == '__main__': nmax = 50 n = int(input('请输入总人数:')) num = [] for...#python3.7 if __name__ == '__main__': s = input('Please input a string:\n') print('The string...input a number:\n')) ptr.append(num) print(ptr) 参考资料: Python 100例
#python3.7 import math for n in range(100,1000): i = math.floor(n / 100)#百位数 j = math.floor...(3)如果n不能被k整除,则用k+1作为k的值,重复执行第一步 #python3.7 def reduceNum(n): print('{} = '.format(n)) if not...#python3.7 score = int(input('输入分数:\n')) if score >= 90: grade = 'A' elif score >= 60: grade...#python3.7 from functools import reduce Tn = 0 Sn = [] n = int(input('n = ')) a = int(input('a = ')...100例 2、Python练习题009:水仙花数:https://www.cnblogs.com/iderek/p/5958568.html
给定一个数字,写一个函数输出其反向数字。(例如,给出123答案是321),数字应该保留他们的标志,即反转时负数仍应为负数。
#python3.7 if __name__ == '__main__': a = 234 b = ~a print('The a\'s 1 complement is %d'...#python3.7 from tkinter import * if __name__ == '__main__': canvas = Canvas(width = 800, height...#python3.7 from tkinter import * if __name__ == '__main__': canvas = Canvas(width=300, height=300...#python3.7 from tkinter import * if __name__ == '__main__': root = Tk() root.title('Canvas')...#python3.7 sStr1 = 'strlen' print(len(sStr1)) 参考资料: 1、Python 100例 2、python3图形界面简单案例(tkinter):https:/
#本人的运行环境为python3.7 count = 0 for i in range(1,5): for j in range(1,5): for k in range(1,5...#python3.7 I = int(input("Please enter the current month's profit:")) arr = [1000000, 600000, 400000...#python3.7 for i in range(1,85): if 168 % i ==0: j = 168 / i if i > j and (i + j...程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天,特殊情况,闰年且输入月份大于2时需考虑多加一天 #python3.7 year = int(input('Year:'...例:http://www.runoob.com/python/python-100-examples.html
/usr/bin/python #coding=utf-8 if __name__ == '__main__': zi = int(input('输入一个数字:\n')) n1 = 1.../usr/bin/python #coding=utf-8 if __name__ == '__main__': a = 'Py' b = 'thon' c = a + b.../usr/bin/python #coding=utf-8 if __name__ == '__main__': class student: x = 0 c.../usr/bin/python #coding=utf-8 if __name__ == '__main__': n = 1 while n <= 7: a = int.../usr/bin/python #coding=utf-8 from sys import stdout if __name__ == '__main__': a = int(input('输入四个数字
#python 3.7 a = ['one', 'two', 'three'] for i in a[::-1]: print(i) 33、按逗号分隔列表。...#python 3.7 L = [1, 2, 3, 4, 5] s = ','.join(str(n) for n in L) print(s) 34、练习函数调用。...#python 3.7 def hello_world(): print('hello world') def three_hellos(): for i in range(3):...#python 3.7 lower = int(input('输入区间最小值:')) upper = int(input('输入区间最大值:')) for num in range(lower, upper...: if (num % i) == 0: break else: print(num) 参考资料: 1、Python
#python3.7 if __name__ == '__main__': ptr = [] for i in range(5): num = int(input('Please...#python3.7 if __name__ == '__main__': a = [1, 2, 3] b = [3, 4, 5] a.sort() #对列表a进行排序...#python3.7 if __name__ == '__main__': for i in range(5): n = 0 if i !...#python3.7 def peven(n): i = 0 s = 0.0 for i in range(2, n + 1, 2): s += 1.0 / i...#python3.7 if __name__ == '__main__': person = {'Alice':13, 'Bob':35, 'May':56, 'Lin':29} m
# -*- coding: utf-8 -*- ''' about numpy.genfromtxt, means generate from txt fil...
这到题用到了字符串的所有字母大写和所有字母小写和字符串拼接,复制,用到的函数有 json 将列表中的内容按照指定字符连接成一个字符串,
100个Python练手小程序,学习python的很好的资料,覆盖了python中的每一部分,可以边学习边练习,更容易掌握python。...2.程序源代码: print ‘Hello Python world!
领取专属 10元无门槛券
手把手带您无忧上云