A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

I am working on problem set zeroi and It all works except how do you program a space between the question and the answer ?

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

    Should be automatic. When I run my ps0.py the output after specifying both inputs has a space between first and last name.

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

    not exactly, if he says print firstname + lastname it will be one word it should look print firstname, lastname (using a ",") if i get what you meant wrong, i apologize

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

    Thanks nessman, thats what I was missing ,Also when it prints each name there is no space between the question and the answer !

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

    i don't understand what you mean there, could you post your code and perhaps the output your having a problem with?

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

    Oh. I see now. I was using print(first_name,last_name) so the space was there automatically.

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

    string_1=raw_input("Enter your last name please" )

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

    and after please there is no space betmeen the e and the first letter of the name

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

    try string_1=raw_input("Enter your last name please\n" ) keeping the "\n" inside the quotes, this moves the cursor to the next line, there are a few other \commands that I remember seeing in our readings

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

    print string_2 + string_1

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

    nice let mne give that a shot

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

    ok I had to go with + " " + to get the blank space inbetween names

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

    that is odd, print string_2, string_1 gives me a space, its important to figure this out as when your working with anything that isn't a string you can't do that easily. eg: you can't number = 1 print number + " "apple" or at least in 2.7, or maybe I have a bigger problem how about your other problem?

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

    yeah the \n puts the response on the next line

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

    Thanks for the help

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

    you could go print number + " " = apple

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

    oops number + " " + apple

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

    Weird, i get the error TypeError: unsupported operand type(s) for +: 'int' and 'str' its something that seriously gets in my way at times

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

    hmmmm

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

    These will all give you the same output (there are others too): print str(number) + ' some string' print number,'some string' print '%d some string'%number

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

    what does "%d some string "% mean?, i have seen the other methods, but not the last

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

    The %d basically says "I want to put an integer here". The %number at the end tells the interpreter to use the integer stored in the variable "number". I probably should have mentioned that this assumes "number" is an integer. You would use %f for a float, %s for a string, etc. You can also use '{0} some string'.format(number), which doesn't care about the variable type. For more info (and more string formatting options), check out: http://docs.python.org/library/stdtypes.html#string-formatting

  22. 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.