r/pythonhelp • • Jun 20 '24

SOLVED Mastering the Recent 'Match Case' Statement - Py 3.10

0 Upvotes

If you've been using Python for a while, you might have missed a significant recent addition to the language: the "Match Case" statement, which serves as Python's answer to the much-anticipated "Switch Statement." This feature, introduced in Python 3.10, has sparked considerable discussion among developers, especially those familiar with similar constructs in other programming languages.

The "Match" statement enables you to compare a value against various patterns and execute the corresponding block of code for the first matching pattern. This improvement eliminates the need for cumbersome nested if-else statements, greatly enhancing the readability of your code. I highly recommend getting acquainted with this new feature, as it is expected to become more prevalent in Python codebases.

For a detailed explanation of how to use the "Match Case" statement, along with other Python tips, check out my YouTube video. Don’t forget to like, comment, and subscribe to support the channel. I hope you find it informative!

https://www.youtube.com/watch?v=2U98PgL-kuI


r/pythonhelp • • Jun 19 '24

Text Based Game: Player cannot leave starting position

0 Upvotes
class Room:
    def __init__(self, name, description=""):
         = name
        self.description = description
        self.items = []
        self.exits = {}

    def add_exit(self, direction, room):
        self.exits[direction] = room
    def add_item(self, item):
        self.items.append(item)


class Item:
    def __init__(self, name, description=""):
         = name
        self.description = description
def setup_rooms():
    rooms = {
        'Bedroom': {'south': 'Kitchen', 'east': 'Bathroom'},
        'Kitchen': {'north': 'Bedroom', 'east': 'Living Room', 'south': 'Laundry Room', 'item': 'Sack of feathers'},
        'Bathroom': {'west': 'Bedroom', 'south': 'Living Room', 'item': 'Master Key'},
        'Closet': {'south': 'Master Bedroom', 'west': 'Bathroom'},
        'Living Room': {'north': 'Bathroom', 'east': 'Master Bedroom', 'west': 'Kitchen', 'item': 'Bucket'},
        'Laundry Room': {'north': 'Kitchen', 'east': 'Garage', 'item': 'Washing Machine'},
        'Master Bedroom': {'north': 'Closet', 'west': 'Living Room'},
        'Garage': {'west': 'Laundry Room', 'north': 'Living Room', 'item': 'Rope'},
    }

    room_objects = {}
    for room_name in rooms:
        room_objects[room_name] = Room(room_name, description=f"This is the {room_name}.")

    for room_name, details in rooms.items():
        current_room = room_objects[room_name]
        for direction, connected_room in details.items():
            if direction != 'item':
                current_room.add_exit(direction.lower(), room_objects[connected_room])
            else:
                item = Item(details['item'])
                current_room.add_item(item)

    return room_objects
def show_instructions():
    print("Revenge on Step Mom")
    print("Collect all the items to progress through the locked Master Bedroom")
    print("Move Commands: South, North, East, West")
    print("Add to Inventory: get 'item name'")


def show_status(current_room, inventory):
    print(f"You are in the {current_room.name}")
    print(f"Inventory: {inventory}")
    if current_room.items:
        for item in current_room.items:
            print(f"- {item.name}")
    print("-------------------")

def check_win_condition(current_room, inventory):
    if current_room.name == 'Master Bedroom' and 'Master Key' in inventory:
        print("Congratulations! You've unlocked the Master Bedroom!")
        print("You tie Sandra up, pour hot tar and feathers all over her! Her screams are like music to your ears.")
        print("You have earned that Capri Sun.")
        return True
    return False
def main():
    show_instructions()

    rooms = setup_rooms()
    current_room = rooms['Bedroom']
    inventory = []

    while True:
        show_status(current_room, inventory)

        command = input("Enter a command: ").lower().strip()
        if command in ['north', 'south', 'east', 'west']:
            if command in current_room.exits:
                current_room = current_room.exits[command]
            else:
                print("I can't go that way.")
        elif command.startswith("get "):
            item_name = command[4:].strip()
            item_found = False
            for item in current_room.items:
                if item.name.lower() == item_name:
                    inventory.append(item.name)
                    current_room.items.remove(item)
                    item_found = True
                    print(f"{item_name} added to inventory.")
                    break
            if not item_found:
                print(f"No {item_name} found here.")
        elif command == 'exit':
            print("Goodbye!")
            break
        else:
            print("Invalid direction")


if __name__ == "__main__":
    main()self.nameself.name

#Ouput
You are in the Bedroom
Enter a command (North, South, East, West, or exit): east
You can't go that way!
You are in the Bedroom
Enter a command (North, South, East, West, or exit): East

A simple text based game for a class. There may be other issues but I can't even leave the bedroom to continue to debug lol


r/pythonhelp • • Jul 03 '24

Recursion in Python

Thumbnail
levelup.gitconnected.com
0 Upvotes

For anyone out there just starting to learn about recursion. I just wrote an article to explain it, hope it's clear enough to give you a good grasp of it, please let me know if it's not, or If you have any questions:

https://levelup.gitconnected.com/python-intermediate-unraveling-the-magic-of-recursion-ac578fa3a0c0


r/pythonhelp • • Jun 14 '24

bubble sort 2D array

0 Upvotes

Anyone knows how to bubble sort the odds of this array and do the same thing to the evens but like put in a new array?? (new arrays should be 1D) No need for codes just the algorithms.

array = [[128, 2], [32, 4], [75, 6]]


r/pythonhelp • • May 25 '24

GPT-2 XL Chatbot response_generation

0 Upvotes

So I've been working with ChatGPT for a few weeks because I have 0 experience in actual coding, on a chatbot application. My file management is terrible, so I've amassed GBs of data on this project. I have been hyper-fixated on this project to the point of working more than 24 hours at a time, but one thing throws me off completely. The response generation is almost never on topic no matter what I set the response generation parameters to or what prompt style I use. I managed once on a half-assed code just playing with the idea. the responses were verbose, but informative, yet, I've not seen it happen again no matter what I do with top_p top_k temperature max_input_tokens etc.. Is there a trick to this that I'm not seeing?


r/pythonhelp • • Jul 10 '24

INACTIVE Is anyone experienced with Moviepy? How does one go about styling captions?

0 Upvotes

I'm hoping to replicate captions similar to this video that I found, with dropshadows over their captions. I'm clueless about how to do this


r/pythonhelp • • Jul 09 '20

I NEED HELP!!

0 Upvotes

I have a reset password API that well reset's a users password, i need to add a validation that throws an error if the user has changed his password to a previously used password, as in he cant use 3 of his recently used password.

I also have a table in POSTGRES that will store the passwords and increment the passwordhistoryid as it comes in.

I dont have much experience in Python , so its abit difficult to understand to logic.


r/pythonhelp • • Jul 19 '20

Hi, can i get some help please? I might just be something small, but i would love if i could get some help. All the info you could need should be in the comments. Thank you!

Post image
0 Upvotes

r/pythonhelp • • Jan 18 '20

“Javadoc” but for python?

0 Upvotes

I’m primarily a java developer and I love that eclipse tells me when theres errors in my code, what functions are available for a given object and info about arguments of functions.

I thought this was kind of a standard for programming and was shocked when I started using python and found that the editor didn’t have this (IDLE i believe?) Is there an IDE that does this or a way I can get this functionality especially also using imports (discord.py, etc.?) thanks!


r/pythonhelp • • Jul 06 '18

How to prevent someone from continuing a quiz?

0 Upvotes

Im trying to make a quiz game with python3. I want to make it for over 13 years olds, so how do i prevent someone how is not over 13yo from continuing.


r/pythonhelp • • Nov 07 '24

Positional argument question

0 Upvotes

I am new to python and trying to write some code and getting the “positional argument follows keyword argument” error but can’t figure out what I’ve done wrong.

from tkinter import * import random; import sys

def red(): print("User selects: RED") global result result = 1

def black(): print("User selects: BLACK") global result result = 2

x = Tk(className = 'Roulette: Red or Black') x.geometry("700x250") x.configure(bg = "gold")

Name = Label(x,text="Roulette: Red or Black?",bg="black",fg="red").grid(row=1,column=1)

Choice = Label(x,text="Enter above Red or Black:\n 'R' for RED\n 'B' for BLACK",bg="black",fg="red").grid(row=3,column=1)

rbtn1=Radiobutton(x,text="Red",value=1, command = red) rbtn1.grid(row=2,column=1) rbtn2=Radiobutton(x,text="Black",value=2, command = black) rbtn2.grid(row=2,column=2)

def Play(): print("User Choice: ", result) if result == 1: UserChoice = Label(x,text="You chose Red!",bg="black",fg="red").grid(row=6,column=1) elif result == 2: UserChoice = Label(x,text="You chose Black!",bg="red",fg="black").grid(row=7,column=1) casino_choice = random.randomrange(3) print("Roulette color: ", casino_choice) if result == casino_choice: Message = Label(x,text="Congratulations!",bg="gold",fg"silver").grid(row=8,column=1) else: Message = Label(x,text="Sorry!",bg="black",fg"white").grid(row=8,column=1)

def Exit(): sys.exit()

btn = Button(x, test='Play Now!',command=Play).grid(row=5,column=1) btn2 = Button(x, test "Quit", command=Exit).grid(row = 10, column = 4)


r/pythonhelp • • Nov 03 '24

Mad Lib issues endless loop

0 Upvotes

HOMEWORK: I am super new to python so my code is an absolute mess. I'm trying to create a program that has 2 stories in it that a user can choose from. Then collects the words to input into the stories. Then it loops back and let's them do another if they'd like and it counts the number of stories they've created.

My link to the trinket I've made so far: https://trinket.io/python3/ba5c267d4262

My issues currently:

this endless loop - I think it's caused by what I've got in def main():

redirecting the user to inputting a correct answer if they put something other than y/n for the do you want to play the game portion

redirect the user to inputting a correct answer if they put something other than A or B for which story they want to do

having a properly function tracker for the story count


r/pythonhelp • • Nov 05 '24

it wont run and i dont know why

0 Upvotes

please can someone help i cant get it to run i get this error:

"

PS C:\Users\Sidne> & C:/Users/Sidne/AppData/Local/Programs/Python/Python313/python.exe c:/Users/Sidne/Desktop/project.py

PS C:\Users\Sidne>

"

import numpy as np

import random

# Define the TicTacToe game class

class TicTacToe:

def __init__(self):

# Initialize the game board as a 3x3 grid filled with zeros

# 0 represents an empty cell, 1 represents Player 1, and -1 represents Player 2

self.board = np.zeros((3, 3), dtype=int)

# Set the starting player; Player 1 (represented by 1) starts the game

self.current_player = 1

def reset(self):

# Resets the board to its initial empty state and sets Player 1 as the current player

self.board = np.zeros((3, 3), dtype=int)

self.current_player = 1

def available_actions(self):

# Returns a list of all available (empty) cells on the board

# Each action is represented as a tuple (i, j) for the cell coordinates

return [(i, j) for i in range(3) for j in range(3) if self.board[i, j] == 0]

def make_move(self, action):

# Make a move on the board at the specified action (i, j) if the cell is empty

if self.board[action] == 0:

# Place the current player's marker (1 or -1) in the specified cell

self.board[action] = self.current_player

# Switch to the other player for the next move

self.current_player = -self.current_player

return True # Move was successful

return False # Move was unsuccessful

def check_winner(self):

# Check if there is a winner in the current board state

# A player wins if any row, column, or diagonal adds up to 3 (Player 1) or -3 (Player -1)

# Check rows and columns for a win

for i in range(3):

# Check row i

if abs(sum(self.board[i, :])) == 3:

return self.board[i, 0] # Return the winning player (1 or -1)

# Check column i

if abs(sum(self.board[:, i])) == 3:

return self.board[0, i] # Return the winning player (1 or -1)

# Check diagonals for a win

# Primary diagonal (top-left to bottom-right)

if abs(self.board[0, 0] + self.board[1, 1] + self.board[2, 2]) == 3:

return self.board[0, 0] # Return the winning player

# Secondary diagonal (top-right to bottom-left)

if abs(self.board[0, 2] + self.board[1, 1] + self.board[2, 0]) == 3:

return self.board[0, 2] # Return the winning player

# If no winner and empty cells remain, game continues (return 0)

# If no empty cells remain, it's a draw (return None)

return 0 if any(0 in row for row in self.board) else None

def display_board(self):

# Display the current board state with X, O, and empty cells

for row in self.board:

# Convert each cell: 1 to 'X', -1 to 'O', and 0 to a blank space

print(' | '.join('X' if x == 1 else 'O' if x == -1 else ' ' for x in row))

print('-' * (3 * 2 - 1)) # Print separator line

# Define a Q-Learning agent for TicTacToe

class QLearningAgent:

def __init__(self, alpha=0.1, gamma=0.9, epsilon=0.1):

# Initialize the Q-table, which maps state-action pairs to Q-values

self.q_table = {}

# Set hyperparameters

self.alpha = alpha # Learning rate: controls how much new information overrides old Q-values

self.gamma = gamma # Discount factor: determines the importance of future rewards

self.epsilon = epsilon # Exploration rate: chance to choose a random action for exploration

def get_q_value(self, state, action):

# Return the Q-value for a given state-action pair, defaulting to 0 if not present in Q-table

return self.q_table.get((state, action), 0.0)

def choose_action(self, state, actions):

# Choose an action based on epsilon-greedy strategy

# With probability epsilon, choose a random action for exploration

if random.uniform(0, 1) < self.epsilon:

return random.choice(actions)

# Otherwise, choose the action with the highest Q-value for the current state

q_values = [self.get_q_value(state, a) for a in actions]

return actions[np.argmax(q_values)] # Select action with maximum Q-value

def update_q_value(self, state, action, reward, next_state, next_actions):

# Update the Q-value for a given state-action pair using the Q-learning formula

# Find the maximum Q-value for the next state (future reward estimation)

max_future_q = max([self.get_q_value(next_state, a) for a in next_actions], default=0)

# Get the current Q-value for the state-action pair

current_q = self.get_q_value(state, action)

# Calculate the new Q-value

new_q = current_q + self.alpha * (reward + self.gamma * max_future_q - current_q)

# Update the Q-table with the new Q-value

self.q_table[(state, action)] = new_q

# Function to train the agent on the TicTacToe game over a series of episodes

def train(agent, game, episodes=5000):

# Loop over a specified number of episodes to train the agent

for episode in range(episodes):

# Reset the game to the initial state at the start of each episode

game.reset()

# Represent the current board state as a tuple (hashable for Q-table)

state = tuple(game.board.flatten())

# Play the game until it ends (win, lose, or draw)

while True:

# Get available actions for the current state

actions = game.available_actions()

# Choose an action based on the Q-learning agent's policy

action = agent.choose_action(state, actions)

# Make the chosen move on the game board

game.make_move(action)

# Get the updated board state after the move

next_state = tuple(game.board.flatten())

# Check if there is a winner after the move

winner = game.check_winner()

# Define rewards based on game outcome

if winner == 1: # Agent wins

reward = 1

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

elif winner == -1: # Opponent wins

reward = -1

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

elif winner is None: # Draw

reward = 0.5

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

else: # Game continues

reward = 0 # No reward yet as the game is still ongoing

# Update Q-value and continue to the next state

agent.update_q_value(state, action, reward, next_state, game.available_actions())

# Update the current state to the next state for the next loop iteration

state = next_state


r/pythonhelp • • Oct 22 '24

Reading Excel to convert Degrees Minutes Seconds to Decimal Degrees

0 Upvotes

Hi all! For reference, I am an adult in my 30's trying to teach myself Python so don't worry about helping some kid cheat on her homework. That's not what's happening here lol

I am using VS Code, Python 3.12, and have Anaconda for Pandas and Openpyxl installed

I am practicing on some super simple data I have in an Excel spreadsheet. This is my first go at creating a code from scratch, with some help and guidance from ChatGPT and online resources-- so please tear it apart if there are better ways to do this!

The raw data is an Excel spreadsheet with three columns: "ID" (being 1, 2, 3, ...) , "Latitude", and "Longitude". The Latitude and Longitude data are string data that look like this: "43-31-25.06"

My goal with the script was threefold: 1) to remove the dashes and decimal point, 2) convert the data into a float, and 3) convert the data from Degrees-Minutes-Seconds format to Decimal Degrees.

Here is my code: https://pastebin.com/VZJdipgy

I keep receiving a Value Error on line 9, where the debugger expected 2 values but got 0.

Any thoughts are so appreciated. I'm brand new to this and I'm teaching myself so I'll take any tips or tricks you have to offer!


r/pythonhelp • • Nov 17 '24

Coding in python

0 Upvotes

Does anyone know of any good sites to help with coding in python.


r/pythonhelp • • Nov 05 '24

this file wont run

0 Upvotes

please can someone help i cant get it to run i get this error:

"

PS C:\Users\Sidne> & C:/Users/Sidne/AppData/Local/Programs/Python/Python313/python.exe c:/Users/Sidne/Desktop/project.py

PS C:\Users\Sidne>

"

import numpy as np

import random

# Define the TicTacToe game class

class TicTacToe:

def __init__(self):

# Initialize the game board as a 3x3 grid filled with zeros

# 0 represents an empty cell, 1 represents Player 1, and -1 represents Player 2

self.board = np.zeros((3, 3), dtype=int)

# Set the starting player; Player 1 (represented by 1) starts the game

self.current_player = 1

def reset(self):

# Resets the board to its initial empty state and sets Player 1 as the current player

self.board = np.zeros((3, 3), dtype=int)

self.current_player = 1

def available_actions(self):

# Returns a list of all available (empty) cells on the board

# Each action is represented as a tuple (i, j) for the cell coordinates

return [(i, j) for i in range(3) for j in range(3) if self.board[i, j] == 0]

def make_move(self, action):

# Make a move on the board at the specified action (i, j) if the cell is empty

if self.board[action] == 0:

# Place the current player's marker (1 or -1) in the specified cell

self.board[action] = self.current_player

# Switch to the other player for the next move

self.current_player = -self.current_player

return True # Move was successful

return False # Move was unsuccessful

def check_winner(self):

# Check if there is a winner in the current board state

# A player wins if any row, column, or diagonal adds up to 3 (Player 1) or -3 (Player -1)

# Check rows and columns for a win

for i in range(3):

# Check row i

if abs(sum(self.board[i, :])) == 3:

return self.board[i, 0] # Return the winning player (1 or -1)

# Check column i

if abs(sum(self.board[:, i])) == 3:

return self.board[0, i] # Return the winning player (1 or -1)

# Check diagonals for a win

# Primary diagonal (top-left to bottom-right)

if abs(self.board[0, 0] + self.board[1, 1] + self.board[2, 2]) == 3:

return self.board[0, 0] # Return the winning player

# Secondary diagonal (top-right to bottom-left)

if abs(self.board[0, 2] + self.board[1, 1] + self.board[2, 0]) == 3:

return self.board[0, 2] # Return the winning player

# If no winner and empty cells remain, game continues (return 0)

# If no empty cells remain, it's a draw (return None)

return 0 if any(0 in row for row in self.board) else None

def display_board(self):

# Display the current board state with X, O, and empty cells

for row in self.board:

# Convert each cell: 1 to 'X', -1 to 'O', and 0 to a blank space

print(' | '.join('X' if x == 1 else 'O' if x == -1 else ' ' for x in row))

print('-' * (3 * 2 - 1)) # Print separator line

# Define a Q-Learning agent for TicTacToe

class QLearningAgent:

def __init__(self, alpha=0.1, gamma=0.9, epsilon=0.1):

# Initialize the Q-table, which maps state-action pairs to Q-values

self.q_table = {}

# Set hyperparameters

self.alpha = alpha # Learning rate: controls how much new information overrides old Q-values

self.gamma = gamma # Discount factor: determines the importance of future rewards

self.epsilon = epsilon # Exploration rate: chance to choose a random action for exploration

def get_q_value(self, state, action):

# Return the Q-value for a given state-action pair, defaulting to 0 if not present in Q-table

return self.q_table.get((state, action), 0.0)

def choose_action(self, state, actions):

# Choose an action based on epsilon-greedy strategy

# With probability epsilon, choose a random action for exploration

if random.uniform(0, 1) < self.epsilon:

return random.choice(actions)

# Otherwise, choose the action with the highest Q-value for the current state

q_values = [self.get_q_value(state, a) for a in actions]

return actions[np.argmax(q_values)] # Select action with maximum Q-value

def update_q_value(self, state, action, reward, next_state, next_actions):

# Update the Q-value for a given state-action pair using the Q-learning formula

# Find the maximum Q-value for the next state (future reward estimation)

max_future_q = max([self.get_q_value(next_state, a) for a in next_actions], default=0)

# Get the current Q-value for the state-action pair

current_q = self.get_q_value(state, action)

# Calculate the new Q-value

new_q = current_q + self.alpha * (reward + self.gamma * max_future_q - current_q)

# Update the Q-table with the new Q-value

self.q_table[(state, action)] = new_q

# Function to train the agent on the TicTacToe game over a series of episodes

def train(agent, game, episodes=5000):

# Loop over a specified number of episodes to train the agent

for episode in range(episodes):

# Reset the game to the initial state at the start of each episode

game.reset()

# Represent the current board state as a tuple (hashable for Q-table)

state = tuple(game.board.flatten())

# Play the game until it ends (win, lose, or draw)

while True:

# Get available actions for the current state

actions = game.available_actions()

# Choose an action based on the Q-learning agent's policy

action = agent.choose_action(state, actions)

# Make the chosen move on the game board

game.make_move(action)

# Get the updated board state after the move

next_state = tuple(game.board.flatten())

# Check if there is a winner after the move

winner = game.check_winner()

# Define rewards based on game outcome

if winner == 1: # Agent wins

reward = 1

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

elif winner == -1: # Opponent wins

reward = -1

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

elif winner is None: # Draw

reward = 0.5

agent.update_q_value(state, action, reward, next_state, [])

break # End episode

else: # Game continues

reward = 0 # No reward yet as the game is still ongoing

# Update Q-value and continue to the next state

agent.update_q_value(state, action, reward, next_state, game.available_actions())

# Update the current state to the next state for the next loop iteration

state = next_state


r/pythonhelp • • Jun 28 '21

SOLVED This example segment of my code worked jut fine before, but gives syntax errors regardless of where I run it. I even tried running a simple print statement and that didn't work. Is something wrong with VS Code?

0 Upvotes

(Solved) see more info in the comments


r/pythonhelp • • Jul 17 '21

finding average balance condition: users above certain age

0 Upvotes

columns: acc_id, name, balance, acc_type, age

how do I code the question: find the average balance of users age 50 or greater.


r/pythonhelp • • Mar 08 '22

average of levels in the tree recursive python

0 Upvotes

hi can someone help me with this I would like to know how can I find the average of levels in the tree recursive python, I know how to do it suing queue but im having problems with the recursions

thank you all


r/pythonhelp • • Mar 04 '22

Physics - white noise, correlation, frames

0 Upvotes

Looking for advice/help on a tutorial sheet pre-exam working with white noise - signals - correlation function etc.

Consider the function s(x) = sin(x). What will the autocorrelation look like?

DM if need more details


r/pythonhelp • • Mar 11 '22

Learning python in graduate level data analytics course. Why aren't I getting a result for sum, mean, and product functions? I only got a result for the print function. I've included all my code and the program feedback I received. Thanks!

0 Upvotes

list=[3, 5, 9, 20, 30, 55, 102, 123, 174]

print(list[4])

add=sum(list)

length=len(list)

average=(sum/len)

product=1

for item in list:

product_list=(product*list)

print(product)

30

TypeError Traceback (most recent call last) /var/folders/2d/hm6tgf712zvfp2zny380hw300000gn/T/ipykernel_4893/3318036303.py in <module>

1 list=[3, 5, 9, 20, 30, 55, 102, 123, 174]

2 print(list[4])

----> 3 add=sum(list)

4 length=len(list)

5 average=(sum/len)

TypeError: 'int' object is not callable


r/pythonhelp • • Feb 25 '22

python question

0 Upvotes
  1. Write a Python program that stores player data in a dictionary.

The idea here is that the user will repeatedly enter a player name and a score. For each name, we maintain a list
of the scores that have been entered.

In a loop, ask the user for a name and then a numerical score, and then ask whether to do another. The prompt
asking for the score should ask for the first score if no score has been entered for that player yet and ask for
another score otherwise. In either case, the score prompt should mention the player by name. The user may
enter the same name more than one time. When a name is entered, check if the name is already in the
dictionary's keys. If it is not (if it's a new name), then add a new pair to the dictionary consisting of the name as
the key and the entered score inside a list as the value. If the name is already among the dictionary keys (the
name already has one or more scores stored for it), then append the current entered score to the end of the list
for that name.

After each score is recorded, ask the user whether to continue, accepting any answer starting with an upper-
case or lower-case Y to mean yes. When the user is done entering names and scores, create a sorted list of the
names. Then, using the sorted list, neatly print out each name and the average score for that player, along with
the best and worst scores for that player. The output should use a consistent numerical format for the average
score and right-justify each output line. See the sample run below for an adequate implementation.

I'm having trouble understanding this assignment, does anybody know what it is asking for and how I should format this?


r/pythonhelp • • Mar 26 '22

don't know how to do recording

0 Upvotes

I have a speech to text when you input an audio file, but I want it the record while I'm pressing a keybind then convert it to text.


r/pythonhelp • • Mar 25 '22

HOMEWORK I need to do this work

0 Upvotes

"Write and run a program that simulates the roll of a dice and counts the number of times an even number comes up and the number of times an odd number comes up. The throw must occur a number of times n, equal to 100 * 20"

I'll be great to receive help