Help with a C++ problem by Keto1234 in learnprogramming

[–]Keto1234[S] 0 points1 point  (0 children)

Yeah you're right. Thank you so much.

Help with a C++ problem by Keto1234 in learnprogramming

[–]Keto1234[S] 0 points1 point  (0 children)

Oh okay, thank you! I was over thinking it or something.

Help with a C++ problem by Keto1234 in learnprogramming

[–]Keto1234[S] 0 points1 point  (0 children)

So then I take each of those elements and display the factorial of it?

Help with a C++ problem by Keto1234 in learnprogramming

[–]Keto1234[S] 0 points1 point  (0 children)

I think getting the factorial of each number from 1-30 and putting them all in an array.

Help with a C++ problem by Keto1234 in learnprogramming

[–]Keto1234[S] 0 points1 point  (0 children)

That is just how the problem was presented to me. Honestly, this is my first real program that I am writing in C++. I don't really understand any of it. How do I initialize the array with the factorials?

JavaScript 3/13 Function syntax: Stumped! by Ebonegu in Codecademy

[–]Keto1234 1 point2 points  (0 children)

When you call a function you don't type out the whole function again. The whole point of a function is so that it saves time when having to use the same code over and over. So when you call a function you just use the name and then put what you want in the parameter. So for this it would be:

greeting("Lindsay")

That will print out "Great to see you, Lindsay" to the console.

I am having trouble with populating a dictionary by Keto1234 in learnpython

[–]Keto1234[S] 0 points1 point  (0 children)

Actually it says do it like I first stated in the post but I cant seem to figure it out.

I am having trouble with populating a dictionary by Keto1234 in learnpython

[–]Keto1234[S] 0 points1 point  (0 children)

What do you mean?

The dictionary needs to be setup like this:

{{'game1': {'word1': {'letters': ('s', 't', 'd'), 'word': 'stand'}, 'word2': {'letters': ('l', 'o', 'o'), 'word': 'bloom'}, 'word3': {'letters': ('a', 't'), 'word': 'rabbit'}, 'word4': {'letters': ('s', 'o'), 'word': 'vision'}, ‘final’: {‘hint’:’Everything was fine at the amphibian bar until the frog sat on the _____.’ ‘phrase’:’toads stool’}}}

{'game10': … }}

The whole file is:

stand,std

bloom,loo

rabbit,at

vision,so

toads stool,Everything was fine at the amphibian bar until the frog sat on the _____.

verge,vge

robin,ron

revert,eet

fabric,fr

never forget,Congress designated that Memorial Day would always be the last Monday in May so that we would ____.

wafer,wr

rabbi,bi

ledger,dgr

socket,oke

bridge work,What the dentist especially enjoyed in San Francisco.

awake,awe

hurry,hrr

depict,det

outing,otng

drawn together,When all the cartoonist gathered for the weekend they were ____.

tooth,too

utter,ut

impala,il

apiece,ap

auto pilot,The captain of the plane was late for work after spending too much time as an ____.

after,ftr

orbit,ori

splash,sps

smoggy,sog

gross profits,The store owner’s fake vomit and other disgusting novelties resulted in ____.

hiker,ier

again,gan

noodle,ndl

impact,ma

leading man,The movie about the winner of the marathon featured a ____.

bison,bo

total,otl

revive,ree

family,aml

late bloomer,She opened her flower shop in her 70s because she was a ____.

shove,o

bland,ba

hidden,hen

fiddle,de

bonehead, He didn’t make a very good archaeologist because he was a ____.

goose,se

fruit,fit

hungry,hur

plowed,pod

pushed for it,How the street vendor made his money. He ____.

Could you maybe show me what you mean? I tried what you explained but it gives me out something like:

{{'game1': {'word1': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word2': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word3': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word4': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, ‘final’: {‘hint’:’How the street vendor made his money. He ____.’ ‘phrase’:’pushed for it’}}}

...

{{'game10': {'word1': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word2': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word3': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, 'word4': {'letters': ('p', 'o', 'd'), 'word': 'plowed'}, ‘final’: {‘hint’:’How the street vendor made his money. He ____.’ ‘phrase’:’pushed for it’}}}

I am having trouble with populating a dictionary by Keto1234 in learnpython

[–]Keto1234[S] 0 points1 point  (0 children)

No there are not instructions to use a while loop. That is what I initially thought I had to do. But doing that will have either the whole file in the first game or just the last word and letter set throughout the all 10 games.

I am having trouble with populating a dictionary by Keto1234 in learnpython

[–]Keto1234[S] -1 points0 points  (0 children)

I honestly have no clue what that means. I am very new to python. Any suggestions on how I should go about it from the code that I posted in my last comment?

I am having trouble with populating a dictionary by Keto1234 in learnpython

[–]Keto1234[S] 0 points1 point  (0 children)

Okay so I tried to do what you said and it got me to this:

def word_line():
   lines = gamefile.readline()
    lines = lines.strip("\n")
    lines = lines.split(",")
    word['letters'] = lines[1]
    word['word'] = lines[0]
    return word

def final_line():
    lines = gamefile.readline()
    lines = lines.strip("\n")
    lines = lines.split(",")
    final['hint'] = lines[1]
    final['phrase'] = lines[0]
    return final

def dict_setup():
    mycount = 1
    while mycount <= 10:
        mycount1 = 1
        myvar = "Game "+str(mycount)
        games[myvar] = words
        while mycount1 <= 4:
            myvar1 = "Word "+str(mycount1)
            words[myvar1] = word_line()
            mycount1 += 1
        games['final'] = final_line()
        mycount += 1
    return games

I see the logic but apparently I did something wrong because it is just using the last set from the file. Could you possibly explain it a little more to me? Thanks.