# This is a sample Python script.
# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import math
import random
rank = 1
avg = 0
class student():
def __init__(self):
self.value = [int(random.random()*30), int(random.random()*40),
int(random.random()*20), int(random.random()*10)] # 중간, 기말, 과제, 출석
if self.value[3] <=6: # 4번 이상 미출결시
self.value = [0,0,0,0]
self.value.append((self.value[0]+self.value[1]+self.value[2]+self.value[3])/4)
def returnValue(self):
return self.value
class school():
def __init__(self):
self.member = []
print('Sch')
class subject(): # 과목 생성
def __init__(self):
self.sub = ['C' , 'C++', 'JAVA' , 'ANDROID', 'PYTHON', 'C#', 'JAVASCRIPT'
, 'SCP', 'SERVERLET', 'WEB']
self.choice=[]
def choose(self):
ran_num = random.randint(0,9)
for i in range(3):
while self.sub in self.choice:
self.choice = [self.sub[ran_num]] #단순 랜덤 반복을 하게 되면 같은 과목이 나올 수 있음. 중복처리
self.choice.append(self.sub[ran_num])
print(self.sub)
# 학생이름, [과목 수 3개], 과목별[중간, 기말, 과제, 출석, 평균]x3, [학점, 등수]
k = int(input('학생 수: '))
xp = school()
for i in range(k):
name = input('이름 입력: ')
subj = subject()
data = student()
xp.member.append([name,[subj.choose()], data.returnValue(), 1])
# member에 subj.choose() 가 for 문을 통해서 과목이 3개가 나오면, data.returnValue의 값도 3번 출력이 되야하는데..
# xp.member.append(1)
for i in range(len(xp.member)):
for j in range(len(xp.member)):
if xp.member[i][1][3] < xp.member[j][1][3] and i != j:
xp.member[i][2] += 1
for i in range(len(xp.member)):
for j in range(len(xp.member[i])):
print(xp.member[i][j])
print()
#
# for i in range(len(xp.member)):
# print(xp.member[i][0], end=': ')
# # if (xp.member[i][1][3] > avg):
# # print(xp.member[i][0], end=': ')
# # avg = xp.member[i][1][3]
# # elif (avg > xp.member[i][1][3]):
# # print(xp.member[i][0], end='(2): ')
# # tmp=xp.member[i]
# # elif (tmp[1][3] > xp.member[i][1][3]):
# # print(xp.member[i][0], end='(3): ')
# avg = xp.member[i][1][3]
# if(avg<xp.member[i][1][3]):
# xp.member[i][1][4]+=1
#
# for j in range(len(xp.member[i][1])-1):
# print('%.2f' %(xp.member[i][1][j] ), end=' ')
# print()
# k=int(input('학생 수: '))
# name = input('이름 입력: ')
#
# class Student():
# # name, kor, eng, math,
# # each class midterm, finalterm, mission
# # example: input Data > name, [90, 90, 100], [100, 200, 300], [100, 100, 100]
# score = []
# def Insert(self, kor, eng, math):
# self.kor= int(random.random()*100)
# self.eng= int(random.random()*100)
# self.math= int(random.random()*100)
#
# def res(self, num):
# for i in range(num):
# self.score
#
# # class School(int, k):
# # members = []
# # def __init__(self):
# # for i in range(100):
# # self.members.append(Student())
# # def __init__(self, k):
# # for i in range(k):
# # self.members.append(Student())
#
#
# def main()
# x=Student()
# y=school(int, k)
# print()
top of page
기능을 테스트하려면 라이브 사이트로 이동하세요.
210124
210124
댓글 0개
좋아요
댓글(0)
bottom of page