1. a=(1,)b=(1),c=("1") 分别是什么类型的数据?
2. 字符串转化大小写
str = "www.runoob.com"
print(str.upper())          # 把所有字符中的小写字母转换成大写字母
print(str.lower())          # 把所有字符中的大写字母转换成小写字母
print(str.capitalize())     # 把第一个字母转化为大写字母,其余小写
print(str.title())          # 把每个单词的第一个字母转化为大写,其余小写 
执行以上代码输出结果为:
WWW.RUNOOB.COm
www.runoob.com
Www.runoob.com
Www.Runoob.Com
3. 统计字符串中某字符出现次数
python统计字符串中指定字符出现的次数,例如想统计字符串中空格的数量
s = "Count, the number of spaces."
print s.count(" ")
x = "I like to program in Python"
print x.count("i")
4.保留两位小数
>>> a=13.949999999999999
上网查了资料,有网友提供了一种方法
>>> print "%.2f" % a 13.95
5.  list=[2,3,5,4,9,6],从小到大排序,不许用sort,输出[2,3,4,5,6,9]
ll=[] 
if len(list)>0:
  m=min(list)
  list.remove(m)
  ll.append(m)
  return ll
1:Python 有哪些特点和优点?
作为一门编程入门语言,Python 主要有以下特点和优点:
可解释
具有动态特性
面向对象
简明简单
开源
具有强大的社区支持
3. 列表和元组之间的区别是?
答:二者的主要区别是列表是可变的,而元组是不可变的。举个例子,如下所示:
x in s | 
True if an item of s is equal to x, else False | 
(1) | 
x not in s | 
False if an item of s is equal to x, else True | 
(1) | 
s + t | 
the concatenation of s and t | (6)(7) | 
s * n or n * s | 
equivalent to adding s to itself n times | (2)(7) | 
s[i] | 
ith item of s, origin 0 | (3) | 
s[i:j] | 
slice of s from i to j | (3)(4) | 
s[i:j:k] | 
slice of s from i to j with step k | (3)(5) | 
len(s) | 
length of s | |
min(s) | 
smallest item of s | |
max(s) | 
largest item of s | |
s.index(x[, i[, j]]) | 
index of the first occurrence of x in s (at or after index i and before index j) | (8) | 
s.count(x) | 
total number of occurrences of x in s | 
s[i] = x | 
item i of s is replaced by x | |
s[i:j] = t | 
slice of s from i to j is replaced by the contents of the iterable t | |
del s[i:j] | 
same as s[i:j] = [] | 
|
s[i:j:k] = t | 
the elements of s[i:j:k] are replaced by those of t | 
(1) | 
del s[i:j:k] | 
removes the elements of s[i:j:k] from the list | 
|
s.append(x) | 
appends x to the end of the sequence (same as s[len(s):len(s)] = [x]) | 
|
s.clear() | 
removes all items from s (same as dels[:]) | 
(5) | 
s.copy() | 
creates a shallow copy of s (same as s[:]) | 
(5) | 
s.extend(t) or s += t | 
extends s with the contents of t (for the most part the same as s[len(s):len(s)]= t) | 
|
s *= n | 
updates s with its contents repeated ntimes | (6) | 
s.insert(i, x) | 
inserts x into s at the index given by i(same as s[i:i] = [x]) | 
|
s.pop([i]) | 
retrieves the item at i and also removes it from s | (2) | 
s.remove(x) | 
remove the first item from s where s[i] ==x | 
(3) | 
s.reverse() | 
reverses the items of s in place | (4) | 
13. 请解释使用 *args 和 **kwargs 的含义
当我们不知道向函数传递多少参数时,比如我们向传递一个列表或元组,我们就使用 * args。
运行结果为:
在我们不知道该传递多少关键字参数时,使用 **kwargs 来收集关键字参数。
位置参数(不要是可变类型),可变参数(*args),默认参数,命名关键字参数(必须按名传参,参数位置可以改变*,名字1,名字2),关键字参数(在最后,以字典的形式打印)
命名关键字参数前如果有可变参数的话,他的*是可以省略额的==
 原文:https://www.cnblogs.com/song-119/p/10168485.html