diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..9b40d205923a233e4f5c2dfbf73e1f75024cec29 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/python.iml b/.idea/python.iml index 5194d1415462226b0f8ffbb53943797ab6a874cc..26ebe51ca7d9bc97ef736d7db527b08d5c61e830 100644 --- a/.idea/python.iml +++ b/.idea/python.iml @@ -1,8 +1,10 @@ - - + + + + diff --git a/face.py b/face.py new file mode 100644 index 0000000000000000000000000000000000000000..9447bdbd87ba8d2bbd49d1423374496dae874c42 --- /dev/null +++ b/face.py @@ -0,0 +1,115 @@ +#1需求编程 +#1.1i.定义了一个学生类:属性:学号,姓名,年龄,性别,身高,体重,成绩,家庭地址,电话号码。行为:学习(要求参数传入学习的时间),玩游戏(要求参数传入游戏名),编程(要求参数传入写代码的行数),数的求和(要求参数用变长参数来做,返回求和结果) +# class student: +# def __init__(self,id,name,age,gender,eight,weight,grades,homeaddress,phone): +# self.id=id +# self.name=name +# self.age=age +# self.gender=gender +# self.eight=eight +# self.weight=weight +# self.grades=grades +# self.homeaddress=homeaddress +# self.phone=phone +# def study(self,time): +# self.time=time +# def playgame(self,gname): +# self.gname=gname +# def code(self,raw): +# self.raw=raw +# def sums(self,*number): +# return sum(number) +# a=student(id=115,name="jacd",age=18,gender="male",eight=175,weight=60,grades="A",homeaddress="asdada",phone=15151161515) +# b=list(map(int,input().split())) +# c=a.sums(*b) +# print(c) + +#1.2ii.车类:属性:车型号,车轮数,车身颜色,车重量,油箱存储大小 。功能:跑(要求参数传入车的具体功能,比如越野,赛车) +# class car: +# def __init__(self,Carmodel,wheels,color,weight,fuel): +# self.Carmodel = Carmodel +# self.wheels = wheels +# self.color = color +# self.weight = weight +# self.fuel = fuel +# def run(self,model): +# self.model = model +# a=car( +# Carmodel = "M", +# wheels = 1, +# color = "red", +# weight = 1, +# fuel = 1, +# ) +# a.Carmodel='法拉利' +# a.run("越野") +# print(a.Carmodel,a.model) + +#1.3笔记本:属性:型号,待机时间,颜色,重量,cpu型号,内存大小,硬盘大小。 行为:打游戏(传入游戏的名称),办公。 +# class mpc: +# def __init__(self,Model, standbytime,color,weight, CPU, memorysize,harddrivesiz): +# self.Model = Model +# self.standbytime = standbytime +# self.color = color +# self.weight = weight +# self.CPU = CPU +# self.memorysize = memorysize +# self.harddrivesiz = harddrivesiz +# def display(self,gamename): +# self.gamename = gamename +# def work(self,workingtime): +# self.workingtime = workingtime + +#2打电话业务逻辑 +class main: + def __init__(self,Name, gender, age, remaining,phonebrand,battery, phonesize,standbytime, pointsowned): + self.Name = Name + self.gender = gender + self.age = age + self.remaining = remaining + self.phonebrand = phonebrand + self.battery = battery + self.phonesize = phonesize + self.standbytime = standbytime + self.pointsowned = pointsowned + def send(self,word): + self.word = word + #判断电话 + def check_phone(self, phone): + if len(phone) != 11: + return False + if not phone.isdigit(): + return False + if phone[0] != "1": + return False + return True + + def call(self,callphone,calltime): + self.callphone = callphone + self.calltime = calltime + if not self.check_phone(callphone): + print("Please enter phone number") + elif self.remaining <1: + print("话费小于1元") + else: + if self.calltime in range(1,11): + self.remaining-=self.calltime + self.pointsowned+=15*self.calltime + elif self.calltime in range(11,21): + self.remaining-=self.calltime*0.8 + self.pointsowned+=39*self.calltime + else: + self.remaining-=self.calltime*0.65 + self.pointsowned+=48*self.calltime + +a = main(Name="张三", gender="男", age=18, remaining=100, + phonebrand="华为", battery=5000, phonesize=6.5, + standbytime=48, pointsowned=200) +b=input() +c=int(input()) +a.call(b,c) +print(a.remaining,a.pointsowned) + + + + diff --git a/fangfa.py b/fangfa.py new file mode 100644 index 0000000000000000000000000000000000000000..7770309f15c2956a0513f6b3f7fd1ba732155e5f --- /dev/null +++ b/fangfa.py @@ -0,0 +1,68 @@ +#1编写一个方法:求4个数的和。 +# def main(): +# a = [] +# for i in range(0,4): +# a.append(int(input())) +# return sum(a) +# b=main() +# print(b) + +#2编写一个方法,传入一个列表,并求出列表的总和 +# a=[1,2,3,4,5,6] +# def main(n): +# return sum(n) +# b=main(a) +# print(b) + +#3编写一个方法,打印99乘法表 +# def main(): +# for i in range(1,10): +# for j in range(1,i+1): +# print(f"{j} x {i} = {i*j}",end=" ") +# print() +# main() + +#4编写方法, 接收一个列表和一个数字,返回这个列表中对应数字的数据,如果数字超出列表长度范围,返回-1. +# a=list(map(int,input().split())) +# b=int(input()) +# def main(n,m): +# if m>len(a): +# return -1 +# else: +# print(n[m-1]) +# main(a,b) + +#5同样使用方法的递归,求1~300所有数的和。(方法调用自己完成操作) +# def main(): +# a=0 +# for i in range(1,301): +# a+=i +# print(a) +# main() + +#6用三个列表表示三个部门的人员情况(一个员工可以同时在多个部门存在) + +# a= ['小明','小张','小黄','小杨'] +# b=['小黄','小李','小王','小杨','小周'] +# c= ['小杨','小张','小吴','小冯','小周'] +# #员工共有多少人 +# sum=list(set(a)|set(b)|set(c)) +# print(len(sum)) +# #求只在一个部门存在的人的数量和对应的名字 +# solo=[] +# nosolo=a+b+c +# for i in nosolo: +# if nosolo.count(i)==1: +# solo.append(i) +# print(len(solo),solo) +# #在两个部门以及以上的人员有哪些 +# print(set(sum)^set(solo)) + +#7编程实现NxN的乘法表的倒叙打印 +def main(): + n=int(input()) + for i in range(n,0,-1): + for j in range(1,i+1): + print(f"{i} x {j} = {i*j}",end=" ") + print() +main() \ No newline at end of file