有12个学生,每个学生的数据包括学号、姓名、三门课程的成绩及其平均分。首先输入这12个学生的数据,然后再计算每个学生3门课程的平均分,并输出第6号学生的所有信息。
时间: 2023-12-15 10:00:23 浏览: 26
return False
return True
# 移除出牌的牌
def remove_cards(self, player, cards):
for card in cards:
self.player_cards[player].remove(card)
# 下一个出牌的玩家
def next_player(self):
下面是一个Python程序,可以实现你需要的功能:
```python
# 定义一个学生类
class Student:
index = self.players.index(self.current_player)
index = (index + 1) % 3
self.current_player = self def __init__(self, number, name, score1, score2, score3):
self.number = number
self.name = name
self.score1 = score1
self.score2 = score2
self.score3 = score3
self.players[index]
# 检查游戏是否结束
def check_game_over(self):
for player in self.players:
if.average_score = (score1 + score2 + score3) / 3
# 输入12个学生的数据
students = []
not self.player_cards[player]:
print(f'{player}获胜!')
return player
return None
# 计算for i in range(12):
number = input("请输入第{}个学生的学号:".format(i+1))
得分
def calculate_score(self):
for player in self.players:
if player == self.last_player:
self.score[player name = input("请输入第{}个学生的姓名:".format(i+1))
score1 = float(input("请输入第{}] += 2
if not self.player_cards[player]:
if player == self.last_player:
self.score[player] += 个学生的第1门课程成绩:".format(i+1)))
score2 = float(input("请输入第{}个3
else:
self.score[player] += 1
print('得分情况:')
for player in self学生的第2门课程成绩:".format(i+1)))
score3 = float(input("请输入第{}个学.players:
print(f'{player}: {self.score[player]}分')
# 开始游戏
def start_game(self):
生的第3门课程成绩:".format(i+1)))
student = Student(number, name, score1, score2 print('欢迎来到斗地主游戏!')
for i in range(3):
player = input(f'请输入第, score3)
students.append(student)
# 输出第6号学生的所有信息
student = students[5]
print("第{i+1}位玩家的昵称:')
self.add_player(player)
self.shuffle_cards()
self.deal_cards6号学生的学号为:{}".format(student.number))
print("第6号学生的姓名为:{}".format(student.name()
print('发牌结果:')
for player in self.players:
print(f'{player}: {self.player_cards[player]}))
print("第6号学生的第1门课程成绩为:{}".format(student.score1))
print("第6号')
print(f'底牌: {self.bottom_cards}')
self.bid_score()
self.take_bottom_cards()
self.play_cards学生的第2门课程成绩为:{}".format(student.score2))
print("第6号学生的第3门()
self.calculate_score()
# 运行游戏
game = DouDiZhu()
game.start_game()
```
运行结果:
课程成绩为:{}".format(student.score3))
print("第6号学生的平均分为:{}".format(student.average_score))
```
你可以直接复制上面的代码到Python环境中运行,按照提示输入数据即可。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![text/x-c](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)