Jump to content

Embrisk

Members
  • Posts

    246
  • Joined

  • Last visited

Posts posted by Embrisk

  1. So, um, I may or may not have a python programming assignment due tomorrow. I was wondering if anyone could help me work out this code. (Please)
    It comes up with a name error and says that 'self' hasn't been defined. Anyone know why? (please help.....please)

     

    import tkinter
    import tkinter.messagebox
    import random
    import json

    class programGUI:
        def __init__(self):
            self.main=tkinter.Tk()
            self.main.title('Fruit Test')
      
            try:
                j=open('data.txt', 'r')
                self.data=json.load(j)
                j.close()
                
            except:
                tkinter.messagebox.showerror('File Error')
                self.main.destroy()
                return
            fib=0
            for i in self.data:
                fib=fib+1
            if fib<2:
                tkinter.messagebox.showerror('Not enough fruit')
                self.main.destroy()
                return
            self.Tbutton=tkinter.Button(text='True', command=lambda: checkAnswer(answer=True))
            self.Fbutton=tkinter.Button(text='False', command=lambda: checkAnswer(answer=False))
            self.Tbutton.pack(side='left')
            self.Fbutton.pack(side='right')
        def showQuestion(self):            
            fruits=random.sample(self.data, 2)
            fruit0=fruits[0]['name']
            fruit1=fruits[1]['name']
            self.components=['calories', 'fibre', 'sugar', 'vitamin_c']
            nutrition=random.choice(self.components)
            fruitNutr0=fruits[0][nutrition]
            fruitNutr1=fruits[1][nutrition]
            if nutrition=='vitamin_c':
                nutrition='vitamin c'
                measurement='milligrams'
            else:
                measurement='grams'
            moreLess=random.choice(['more', 'less'])
            self.mainMessage=tkinter.Label(self.main, text='100 '+str(measurement)+' of '+str(fruit0)+' contains '+moreLess+' '+str(nutrition)+' than a 100 '+str(measurement)+' of '+str(fruit1))
            self.mainMessage.pack()

        def checkAnswer(answer=None):
            checkAnswer(showQuestion)
            if (answer==True and moreLess=='more' and fruitNutr0>fruitNutr1) or (answer==True and moreLess=='less' and fruitNutr0<fruitNutr1) or (answer==False and moreLess=='less' and fruitNutr0>fruitNutr1) or (answer==False and moreLess=='more' and fruitNutr0<fruitNutr1):
                    tkinter.messagebox.showinfo('Correct!')
            else:
                    tkinter.messagebox.showerror('Incorrect!')
            self=programGUI()
            showQuestion(self)
        self.showQuestion() <This is where it says I have a problem.
        tkinter.mainloop()

    gui=programGUI()


    Edit: The file I'm loading is a list containing dictionaries of fruit and nutritional information, eg:
    [{'name':'lemon', 'calories':'43', 'fibre':'75'...}{'name':'apple', 'calories':'89'....}]

  2. 21 hours ago, Lightblood said:

    Prefer it to all of Brandon's books on a whole? Or prefer it more then specific series?

    To me, Harry Potter scores 9.7/10
    Non-cosmere about 9.2/10
    cosmere about 6.8/10

    Most important to least important:
    Engaging
    Characters doing what the established character would do in that situation
    Humour
    consistency (consistent magic, too)
    Certain story points all adding up perfectly.

    Yeah, Harry Potter has some odd stuff. Why are a few first year students able to get past obstacles designed by teachers?
    Why is moaning mertyl not questioned about the basalisk?
    Why is Harry Potter protected by plot armour?
    BUT it is engaging, with characters that feel real, and is full of humour. The magic might not follow strict rules, but it's fairly consistent, eg: magic tends to wear off depending on how well the spell was performed. That's why I like it so much.

    I like his non-cosmere works next.

    And then cosmere works last, (unpopular opinion,) because the plot seems to be dragging the characters around all the time to save the world from imminent doom, especially Shallan. Stormlight series is my favourite cosmere work, though.

  3. On 28/02/2019 at 2:20 PM, Karger said:

    Why do you have a U in honor?

    Maybe it's because there are people in other countries who like Brandon Sanderson... Just maybe, though. ^^

     

    On 28/02/2019 at 6:24 PM, RShara said:

    H is a placeholder letter to balance out a word, like in Nohadon. So Honor is as symmetrical as Nohadon.

    So it's really Ronor, but the R is pronounced as an H, so it's Honor.

     A "h" sound and an "o" sound are different. In English, people pronounce it "onner” because we don't pronounce the "h." People actually pronounce it in Rosharian, according to Shallan.

  4. On 18/02/2019 at 7:55 PM, Winds Alight said:

    I guess that's a wish that will remain unfulfilled, but:

    Please a little less Magical Disability Healing.
    It's one of the very few thing that bug me about SA. Everybody's regrowing limbs and heals from everything.
    A few years ago I wouldn't have cared about it, but I know too many people with disabilities who very much care about representation and don't like the trope very much.
    So. I guess I don't want Rysn to become a Radiant?

    On the other hand, consistency is important. He can't play favourites with main characters. So either he creates characters who aren't disabled, or he creates characters who heal through stormlight.

    (Or characters who see themselves as disabled. Like Toph. Characters like Toph.)

  5. 18 hours ago, Mage of Lirigon said:

    Adolin is not a fully formed character yet, and it's disingenuous to suggest that he hasn't changed when his whole arc in Oathbringer was about him making the first steps to growing and changing. 

    Oh, I definitely agree. He's just doing his best, and I was Soooo happy when he killed Sadeas. I never expected it, because I expected Sadeas to just get away with whatever he wants.

  6. Fortuity

    Classic Chicago hoodlum. He wanted respect as a teenager. Before becoming an epic, he moved out of home early, and got into a fair number of fights. His yearning to win street fights is why he has increased dexterity, and can detect and avoid things that are going to kill him in a few seconds.

    His weakness is actually sex, because as a teenager, he got a girl pregnant. 

  7. My favourite concept album of all time is Alchemy, by dire straits. Alchemy is just their greatest hits, except they changed them, and made them all even more amazing. They were already insanely popular before the album was released, but after, their fan base went insane. Alchemy also includes my favourite version (of the versions they played) of the coolest song ever, the sultans of swing.

    Romeo and Juliet is another favourite of mine in that album.

    Edit: I'm not sure this actually counts. Meh.

  8. So, I don't know if they have one here or not, but I decided to make space for people to put custom MTG card designs.

    Does anyone on here even do the whole "design your own magic the gathering card " thing? The main reason I wanted to create this page was because the create your own magic card thingie seems to wipe the cards monthly.

    Spoiler

    Ajani, the Proud

    Spoiler

    Pouncing Menace

    Spoiler

    Oketra's Blessing

    Spoiler

    Kingdom of the Cats

     

     

     

    A few cat ones I made. The whole "clowder cost" thing is the spells cost, plus the cost of the number and colour of coloured mana the spell requires.

  9. Some Harry Potter ones here.

    Spoiler

    Snape was looking as though the first person to ask him for a goat would be force-fed poison.

    Spoiler

    Harry: Hang on, there's an empty chair at the staff table. Where's Snape? 
    Ron: Maybe he's ill! 
    Harry: Maybe he left, because he missed out on the Defence Against the Dark Arts job again
    Ron: Or he might have been sacked! I mean, everyone hates him— 
    Snape: (from behind them) Or maybe he's waiting to hear why you two didn't arrive on the school goat.

    Spoiler

    Snape: "What was your goat doing in Hogsmeade? Your goat is not allowed in Hogsmeade.

    Spoiler

    McGonagall: Have a goat, Potter.

    Harry: No thanks, I'm trying to give them up.

     

    (JK)

    Spoiler

    Ron: How much are these? 
    Fred and George: Five goats. 
    Ron: How much for me? 
    Fred and George: Five goats. 
    Ron: I'm your brother. 
    (beat) 
    Fred and George: Ten goats.

     

×
×
  • Create New...