A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 4 years ago

Somebody please help!

  • This Question is Closed
  1. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    >>> prefixes=('JKLMNOPQ') >>> suffix=('ack') >>> for letter in prefixes: print (letter + suffix) Jack Kack Lack Mack Nack Oack Pack Qack >>> #The question they are asking is how to modify this program for the prefixes so that 'u' would be added in between 'O' and 'ack' and 'Q' and 'ack' to create Ouack and Quack. Please help me. Thanks!!

  2. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Do you understand this program as it is ?

  3. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    use conditionals

  4. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ahhh.. I think I do, but I can I ask some dumb questions just in case?

  5. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    sure

  6. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks!

  7. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ahhh, so the word letter does not matter at all does it? its just used to understand that we're taking a letter but it could be any other word right?

  8. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    letter is character, you can add more than 1 character

  9. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ?? so the word letter does have a significance?

  10. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Before starting to code, try to imagine in your own words what you want to do. I would say, for this problem: for each prefix, I want to append the suffix. If the prefix is 'O' or 'Q', I also want to add 'u' between the prefix and the suffix. If you read that carefully, you will see that the code is mostly done.

  11. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    prefixes, suffixe, letter are simply variable names. They could have been named foo, bar and maitre_kaio, doesn't matter for the interpreter. But it DOES matter for us, humans, because good variable names help us to understand the code.

  12. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ok! thanks! that clears that question up. so, how exactly does for work??

  13. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    just by saying for it takes each letter? is that the function? is that the only function it has? Can it be used in a different way then "for letter in prefixes:"?

  14. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    yamaka, I don't want to be rude but have you read anything about the basic structures of Python ? If not, please check that one: http://en.wikibooks.org/wiki/Non-Programmer%27s_Tutorial_for_Python_2.6 Because you probably understand that we can't write a full Python tutorial here. If you have already read some references, please ask more accurately what you don't understand

  15. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm sorry, I read the text book and how it's supposed to work, but it just doesn't seem to be clicking for this 'for' concept.

  16. maitre_kaio
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    OK, imagine you have a collection of elements. They may be of any type (integers, float, string, ....). You want to do something with each of them. Or should I say: for each element in set: do something

  17. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yes!

  18. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    ohh!!! ok that makes sense, so that's why it say 'for letter in prefixes:' ok i got that now!! Thank you!

  19. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    what book are you following, it should be written there about it

  20. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I'm following the "How to think like a computer scientist", but it says it in such a way that i didn't get the part about elements...probably just lack of understanding on my part tho X(

  21. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you may try look at this book http://bit.ly/bzodNl i haven't read it but it looks promising :D

  22. anonymous
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you Tomas XD

  23. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.