01

f = 30.5ff = str(f)print(type(ff))#输出结果为 class 'str'

02

s = int(input("请输入分数:"))if 80 >= s >= 60:    print("及格")elif 80 < s <= 90:    print("优秀")elif 90 < s <= 100:    print("非常优秀")else:    print("不及格")    if s > 50:        print("你的分数在60分左右")    else:        print("你的分数低于50分")

03

l = [1,2,2,3,6,4,5,6,8,9,78,564,456]n = l.index(6, 0, 9)print(n)#输出结果为  4

04

#取元组下标在1~4之间的3个数，转换成列表t = (1,2,3,4,5)print(t[1:4])l = list(t)print(l)#在列表下标为2的位置插入1个6l[2]=6print(l)#讲修改后的列表转换成元组并输出t=tuple(l)print(t)
#运行结果为：(2, 3, 4)[1, 2, 3, 4, 5][1, 2, 6, 4, 5](1, 2, 6, 4, 5)

05

"{0} 嘿嘿".format("Python")a=100s = "{0}{1}{2} 嘿嘿"s2 = s.format(a,"JAVA","C++")print(s2)#运行结果为：100JAVAC++ 嘿嘿

a=100s = "{}{}{} 嘿嘿"s2 = s.format(a,"JAVA","C++","C# ")print(s2)#运行结果为：100JAVAC++ 嘿嘿

s = "{a}{b}{c} 嘿嘿"s2 = s.format(b="JAVA",a="C++",c="C# ")print(s2)#运行结果为：C++JAVAC#  嘿嘿

06

d = {"name": "小黑"}print(d.get("name2", "没有查到"))print(d.get("name"))
#运行结果为：没有查到小黑

07

def fun1():    global b    b=100    print(b)fun1()print(b)
#运行结果为：100100

08

#多线程的创建class MyThread(threading.Thread):    def __init__(self,name):        super().__init__()        self.name = name    def run(self):        #线程要做的事情        for i in range(5):            print(self.name)            time.sleep(0.2) #实例化子线程t1 = MyThread("凉凉")t2 = MyThread("最亲的人")t1.start()t2.start()

09

from my_package1 import my_module3print(my_module3.a)my_module3.fun4()

10

（1）常规文件操作

file的对象属性

file对象的方法

（2）OS模块

• 关于文件的功能

• 关于文件夹的功能

11

class B:    age = 10    def __init__(self,name):        self.name = name    @classmethod    def eat(cls): #普通函数        print(cls.age)    def sleep(self):        print(self)b = B("小贱人")b.eat()#运行结果为:10

12

import res = "abcabcacc"l = re.split("b",s)print(l)#运行结果为：['a', 'ca', 'cacc']