摘要: 变量: 作用 记录状态,写程序处理状态的变化 字符串 数字 列表 元祖 字典 用来存放不同状态 可变可不变: 不可变:你修改变量的值,但是他的id变化的,这个变量是不可变的 字符串 数字 元祖 >>> name = "aaa" >>> print(name) aaa >>> name 'aaa' > 阅读全文
posted @ 2018-04-27 00:26 悟悾 阅读(105) 评论(0) 推荐(0)
摘要: 字典(dict): 1、基本结构: info = { "k1:v1", 键值对, "k2:v2" } 2、字典的v可以是任何值 3、字典的k可以是字符串、数字,可以是元祖,不可以是列表、字典, 4、字典不可以作为字典的k 5、字典不是有序的 2、取值 v = info(k1) print(k1) 可 阅读全文
posted @ 2018-04-27 00:23 悟悾 阅读(149) 评论(0) 推荐(0)
摘要: 元祖(tuple):是对列表的一个二次加工,元素不可被修改不能被增加或删除,可以查看 (类)tuple:(元祖) (对象)tu = (111,222,333) (类)list:(列表) (对象)tu = [111,222,333] 一般在写元祖,在最后一个参数加一个逗号v = (111,2222,3 阅读全文
posted @ 2018-04-25 23:27 悟悾 阅读(264) 评论(0) 推荐(0)
摘要: 列表(list): class list(object):(list类中提供的方法) """ list() -> new empty list list(iterable) -> new list initialized from iterable's items """ 1、def append( 阅读全文
posted @ 2018-04-25 23:26 悟悾 阅读(96) 评论(0) 推荐(0)
摘要: 集合: 是由不同元素组成、无序、不可变类型(数字、字符串、元祖) s = {1,2,3,4,} >>> s = {1,1,22,22,22,33,33,3,44,44} >>> type(s) <class 'set'> >>> s {1, 33, 3, 44, 22} 集合可以去重复的,得到的还是 阅读全文
posted @ 2018-04-25 23:25 悟悾 阅读(108) 评论(0) 推荐(0)
摘要: #include<stdio.h>int main(){ int i, j;//注意:在九九乘法表中没有0很任何数相乘 for (i = 1; i <= 9; i++)//第一个for循环控制列的循环 { for (j = 1; j <= i; j++) { printf(" | %d*%d=%2d 阅读全文
posted @ 2018-04-03 23:26 悟悾 阅读(115) 评论(0) 推荐(0)
摘要: #include<stdio.h>int main(){ int i; for (i = 0, printf(" A"); printf(" B")&&i == 0 ; i++, printf(" D\n")) { printf(" 代码段C\n"); } printf("\nfor循环结束"); 阅读全文
posted @ 2018-04-03 23:08 悟悾 阅读(75) 评论(0) 推荐(0)
摘要: count = 0sum = 0while count < 100: count = count + 1 sum = sum +count print(sum)//实现了1-100所有数字的和 n = 1while n < 101: temp = n % 2 if temp != 0: pass e 阅读全文
posted @ 2018-04-03 00:19 悟悾 阅读(133) 评论(0) 推荐(0)
摘要: 100内的奇数和 奇数个数 偶数和 偶数的个数 #include<stdio.h> int main (){ int i; int sum=0; int sum1=0; int sum2=0; for (i=1;i<=100;i=i+2) { sum=sum+i; } int cnt=0; for 阅读全文
posted @ 2018-03-29 23:55 悟悾 阅读(106) 评论(0) 推荐(0)