原文链接:http://www.cnblogs.com/CheeseZH/archive/2012/11/05/2755107.html 无论学习哪门计算机语言,只要把100例中绝大部分题目都做一遍,就基本掌握该语言的语法了. [程序1] 题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? #Filename:001.py cnt = 0#count the sum of result for i in range(1,5): for j in range(1,5…
# -*- coding: utf-8 -*- #python 27 #xiaodeng #python之模块copy,了解概念即可 import copy #浅拷贝 #copy拷贝一个对象,但是对象的属性还是引用原来的 #x = copy.copy(y) # make a shallow copy of y #深拷贝 #deepcopy拷贝一个对象,把对象里面的属性也做了拷贝,deepcopy之后完全是另一个对象了 #x = copy.deepcopy(y) # make a deep cop…
python求100以内素数之和 from math import sqrt # 使用isPrime函数 def isPrime(n): if n <= 1: return False for i in range(2, int(sqrt(n)) + 1): if n % i == 0: return False return True count = 0 for i in range(101): if isPrime(i): count += i print(count) # 单行程序扫描素数…
Python练习100题 题目:有1.2.3.4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少? #Filename:001.py cnt = 0#count the sum of result for i in range(1,5): for j in range(1,5): for k in range(1,5): if i!=j and i!=k and j!=k: print i*100+j*10+k cnt+=1 print cnt [程序2] 题目:企业发放的奖金根据利润…
package com.swift; public class String_To_Integer_Test { public static void main(String[] args) { /* * 编程求字符串“100”和“150”按十进制数值做差后的结果以字符串形式输出. */ String str1="100"; String str2="150"; int i1=Integer.valueOf(str1); int i2=Integer.valueOf…