Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
CarForumPoster
Jun 26, 2013

⚡POWER⚡
lol at complaining to the dean that some teacher doesn’t like your coding style

I’m sure they’ll get RIGHT on that

But yes if this lady could code competently she’d make $100k doing it and not $40k. Also camel case in Python so you know she don’t know Python.

Adbot
ADBOT LOVES YOU

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Computer viking posted:

It's more "has a long history of assignments where she only accepts outright wrong answers", from what we've seen.

Oh I agree theyre incompetent and terrible. OP needs to know more than OP knows now to articulate why that is and reap any benefit. Like yea they can whistle blow, but how does OP gain from that? The type of person who is so dumb and bad at coding to do what we're accusing them of here is the type to retaliate.

CarForumPoster
Jun 26, 2013

⚡POWER⚡
I’m all for doing something to achieve that outcome but he should know it carries some risk. I suspect he’s gonna need some political capital or an exceptionally well articulated argument for that to happen.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Volmarias posted:

As others mentioned, figure out what your professor is trying to get the class to do and do that. This is an extremely dumb way to try to teach people to use recursion if that is indeed the case; there's so many better examples that aren't terrible!

Also, saying "we don't use break statements" makes me want to say "ok cool,

[...]

I'm not using break here or while loops! We're good, right?" :fuckoff:

Generally agree. I'm betting this is getting him to figure out recursion and probably to break nested for loops into a few functions that more clearly explain whats going on. Maybe something like this (generated with chatGPT, havent tested but it gets to the point)

code:
import random
import time

def roll_dice():
    return random.randint(1, 6)

def take_turn(current_player, player_one_score, player_two_score):
    print(f"It's {current_player}'s turn.")
    turn_score = 0

    def roll_again():
        nonlocal turn_score
        roll = roll_dice()
        print(f"{current_player} rolls a {roll}")
        time.sleep(1)  # for ease of play

        if roll == 1:
            print("You rolled a 1. Switching to the other player's turn.")
            time.sleep(1)
            return switch_player(current_player, turn_score, player_one_score, player_two_score)
        else:
            turn_score += roll
            print(f"{current_player}'s score: {player_one_score + turn_score if current_player == 'Player One' else player_two_score + turn_score}")
            choice = input("Roll again? (y/n): ").lower()
            if choice == 'n':
                return switch_player(current_player, turn_score, player_one_score, player_two_score)
            return roll_again()

    return roll_again()

def switch_player(current_player, turn_score, player_one_score, player_two_score):
    if current_player == "Player One":
        player_one_score += turn_score
        current_player = "Player Two"
    else:
        player_two_score += turn_score
        current_player = "Player One"
    
    if player_one_score >= 30 or player_two_score >= 30:
        return (player_one_score, player_two_score)
    
    return take_turn(current_player, player_one_score, player_two_score)

def play_game():
    player_one_score, player_two_score = take_turn("Player One", 0, 0)
    if player_one_score >= 30:
        print(f"Congratulations! Player One wins with a score of {player_one_score}")
    elif player_two_score >= 30:
        print(f"Congratulations! Player Two wins with a score of {player_two_score}")

play_game()

If you like discrete event simulations like this, I'd also suggest looking at SimPy. I've used it to do business predictions for the expected value of projects and made some surprisingly accurate predictions about the future. Prob gonna use a while loop tho.

CarForumPoster fucked around with this message at 20:37 on May 4, 2024

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply