num

作业六

混江龙づ霸主 提交于 2020-02-01 11:51:12
#第一题: #fruitList=["梨子","苹果","香蕉","橘子","西瓜","芒果","柚子"] #fruit_num=len(fruitList) #print(fruit_num) #第二题: #fruit_en_List=["Pear","Apple","Banana","Orange","Watermelon","Mango","Pomelo"] #fruit_cn_List=["梨子","苹果","香蕉","橘子","西瓜","芒果","柚子"] #index=0 #while True: # fruit_en=fruit_en_List[index] # fruit_cn=fruit_cn_List[index] # user=input("请输入"+fruit_en+"的中文翻译是:") # if user==fruit_cn: # print("回答正确") # else: # print("回答错误") # index=index+1 # if index==7: # break #第三题: #lengthList=["毫米(mm)","厘米(cm)","分米(dm)","米(m)","千米(km)"] #resList=["瓜子","橡皮","桌子","门","公路"] #while True: # name=input("请输入物品的名字:") #

007、Java中定义int型变量

爷,独闯天下 提交于 2020-02-01 11:08:20
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { // 为变量设置内容使用如下格式:数据类型 变量名称 = 常量 ; int num = 10 ; // 10是常量,常量的默认类型是int int result = num * 2 ; // 利用num变量的内容乘以2,并且将其赋值给result System.out.println(result) ; // 输出result变量 } } 02.效果如下: 知识有价,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。 来源: https://www.cnblogs.com/tianpan2019/p/12247742.html

008、Java中变量与常量的区别

那年仲夏 提交于 2020-02-01 11:05:21
01.代码如下: package TIANPAN; /** * 此处为文档注释 * * @author 田攀 微信382477247 */ public class TestDemo { public static void main(String[] args) { // 所有的变量名称在同一块代码中只允许声明一次 int num = 10; // 10是常量,常量的默认类型是int // 取出num变量的内容乘以2,并且将其设置给num变量 num = num * 2; System.out.println(num); } } 02.效果如下: 知识有价,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢。 来源: https://www.cnblogs.com/tianpan2019/p/12247752.html

如何书写高效的MySQL查询?

纵饮孤独 提交于 2020-02-01 10:22:20
How to write efficient MySQL query statements WHERE子句中的书写注意事项 模糊查询(like)时需要注意的事项 索引 字段类型 表连接时的注意事项 其他注意事项 WHERE 子句中的书写注意事项 首先应考虑在 where 及 order by 涉及的列上建立索引。 下列操作会导致引擎放弃使用索引而进行全表扫描,是应尽量避免的。 1).在 where 子句中使用 != 或 <> 操作符 2).在 where 子句中对字段进行 null 值判断 如: select id from t where num is null; 可以在num上设置默认值0,确保表中num列没有null值,然后这样查询: select id from t where num=0; 3).在 where 子句中使用 or 来连接条件 如: select id from t where num=10 or num=20; 可以这样查询: select id from t where num=10 union all select id from t where num=20; 4).in 和 not in 也要慎用 如: select id from t where num in(1,2,3); 对于连续的数值,能用 between 就不要用 in 如:

巨蟒django之CRM2 展示客户列表&&分页

寵の児 提交于 2020-02-01 09:10:57
1.展示客户列表 点击画红线中的views,进入下列界面 路径的查找顺序:应该是先查找外层的templates里边的html,然后查找app里边的templates 另一个会按照app的顺序进行寻找,在一开始的settings.py里边的配置文件 模板: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>路飞学城</title> <link rel="shortcut icon" href="{% static 'imgs/luffy-study-logo.png' %} "> <link rel="stylesheet" href="{% static 'plugins/bootstrap/css/bootstrap.css' %} "/> <link rel="stylesheet" href="{% static 'plugins/font-awesome/css/font-awesome.css' %} "/> <link rel="stylesheet" href="{% static 'css/commons.css' %} "/> <link rel="stylesheet" href="{% static 'css/nav.css' %} "

MySQL(十二)游标和触发器

纵然是瞬间 提交于 2020-02-01 08:24:57
一、游标 定义: 存储在MySQL服务器上的数据库查询,是一种被select语句检索出来的结果集。 作用: 方便在检索出来的结果集中前进或后退一行或多行。 游标主要用于交互式应用;MySQL中的游标只能用于存储过程(和函数)。 1、创建游标 游标使用declare语句创建;declare命名游标,并定义响应的select语句,根据需要带where和其他子句;例如: create procedure processorders() begin declare ordernumbers CURSOR for select order_num from orders; end; 这个存储过程中,declare定义和命名了游标ordernumbers,存储过程处理完成后,游标消失(因为它局限于存储过程内)。 2、打开和关闭游标 游标使用open cursor语句来打开,例如: open ordernumbers; 在处理open语句时执行查询,存储检索出的数据以供浏览和滚动; 游标处理完成时,使用close语句关闭,例如: close ordernumbers; close释放游标使用的所有内部内存和资源,因此在每个游标不在需要时都应该关闭。 PS: 一个游标关闭后,如果没有重新打开,则不能使用;但如果该游标被声明过,则不需要再次声明,用open语句打开使用即可。 如果不明确游标是否关闭

mysql之触发器trigger

非 Y 不嫁゛ 提交于 2020-02-01 08:24:09
触发器(trigger):监视某种情况,并触发某种操作。 触发器创建语法四要素:1. 监视地点(table) 2. 监视事件(insert/update/delete) 3. 触发时间(after/before) 4. 触发事件(insert/update/delete) 语法: create trigger triggerName after/before insert/update/delete on 表名 for each row #这句话在mysql是固定的 begin sql语句; end; 注:各自颜色对应上面的四要素。 首先我们来创建两张表: #商品表 create table g (   id int primary key auto_increment,   name varchar(20),   num int ); #订单表 create table o (   oid int primary key auto_increment,   gid int, much int ); insert into g(name,num) values('商品1',10),('商品2',10),('商品3',10); 如果我们在没使用触发器之前:假设我们现在卖了3个商品1,我们需要做两件事 1.往订单表插入一条记录 insert into o(gid,much)

7-Java-A-1-阶乘位数

淺唱寂寞╮ 提交于 2020-02-01 05:07:03
阶乘位数 9的阶乘等于:362880 它的二进制表示为:1011000100110000000 这个数字共有19位。 请你计算,9999 的阶乘的二进制表示一共有多少位? 注意:需要提交的是一个整数,不要填写任何无关内容(比如说明解释等) import math num=0 for i in range(1,10000): num=num+math.log2(i) print(int(num+1)) 答案:118445 参考: 我们不直接估计n!,而是考虑它的自然对数: ln(n!) = ln 1 + ln 2 + ... + ln n. 按一般方法计算N的阶乘,其时间复杂度为O(N): N!= 1 * 2 * 3 * 4 * 5 * ............ * N; 如果要计算N后得到的数字为几位数,则我们可以知道其位数等于lgN!+1; 来源: CSDN 作者: tianrandai12 链接: https://blog.csdn.net/tianrandai12/article/details/104094849

求1~N 的数中因子是最多的数

折月煮酒 提交于 2020-02-01 04:07:17
求1~N当中约数个数最多的数”问题的优化 2010-04-13 20:56 【问题描述】 求1~N当中约数个数最多的数,若有多解则输出最小的数。 【输入格式】 输入文件只有一行。这一行有一个数N(1≤N<10^17)。 【输出格式】 输出文件只有一行。这一行有一个数,即所求的数。 【输入样例】 2000 【输出样例】 1680 题目分析: (1)此题最容易想到的是穷举,但是肯定超时。 (2)我们可以知道,计算约数的个数和质因数分解有着很大的联系: 若Q的质因数分解为:Q=p1^k1*p2^k2*…*pm^km(p1…pm为素数,k1…km≥1),则Q有(k1+1)(k2+1)…(km+1)个约数。 但是质因数分解的时间复杂度很高,所以也会超时。 (3)通过以上的公式,我们可以“突发奇想”:为何不能把质因数分解的过程反过来呢? 这个算法就是枚举每一个素数。初始时让m=1,然后从最小的素数2开始枚举,枚举因子中包含0个2、1个2、2个2…k个2,直至m*2^k大于区间的上限N。在这个基础上枚举3、5、7……的情况,算出现在已经得到的m的约数个数,同时与原有的记录进行比较和替换。直至所有的情况都被判定过了。 这个算法的优化:如果p1*p2*p3*……*pk>N(pi表示第i个素数),那么只要枚举到p k-1,既不浪费时间,也不会遗漏。 根据以上的算法

python练习题

此生再无相见时 提交于 2020-02-01 03:53:21
1、使⽤while循环输出 1 2 3 4 5 6 8 9 10 count = 1 while count <= 10 : if count == 7 : count +=1 continue print(count,end=" ") count +=1 num = 1 while num <= 10 : print(num,end=" ") num += 1 #num + 1 2、求1-100的所有数的和 num = 1 h = 0 while num <= 100 : h = h + num num += 1 print(h) 3、输出 1-100 内的所有奇数 num = 1 while num <= 100 : if num % 2 == 1: print(num,end=" ") else: pass num +=1 4、输出 1-100 内的所有偶数 num = 1 while num <= 100 : if num % 2 == 0: print(num,end=" ") else: pass num +=1 5、求1-2+3-4+5 ... 99的所有数的和 num = 1 h = 0 while num < 100 : if num % 2 == 1: h = h + num else : h = h - num num +=1 print(h) 6、用户登陆