Quantcast

A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

ChrisJordan

  • 3 years ago

I'm on lecture 3, however I need some help with the first assignment with the program that asks your your name and d.o.b, I keep getting syntax errors and I have no idea why... Is there a source that can explain all syntax errors on this version of Python?

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

    What errors are you getting? Paste your code and I'll try to help you debug it! :)

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

    @ChrisJordan And if you tag me in the post I'll know when you've pasted it. Thanks!

  3. Larzdk
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Yes, please post your code. Pastebin is pretty good for that stuff :)

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

    Will do as soon as I get off of work at 6pm est.

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

    I've just done this assignment. Without seeing your code, I suppose there are a couple of places that syntax errors may occur. 1. Ensure that you have enough brackets with your raw_input command. 2. Ensure that you enclose your prompt in quote marks. 3. A good idea also is to ensure that your date of birth variable is a string type. I'll give a different example to the assignment: e.g. gen = str(raw_input('Enter your gender:')) Notice two open brackets, two closed brackets. Also notice the quotes around the prompt. Hopefully these are your only errors - when you show the code you will get a definite answer. Cheers

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

    NameError: name 'x' is not defined

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

    1 Attachment
  8. ChrisJordan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I will probably figure out that it is a silly mistake

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

    Hmmm.... It looks like you are using the command line there. Are you using the IDLE GUI to write out your code?

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

    The attached file might help? Please other people let me know if I'm on the complete wrong track too as I'm only new to this too! If you are using a windows machine, download the file, then right click on it and choose "Edit with IDLE". Two windows should open. One is the editor and one is the shell. The example code will hopefully help.

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

    Of course it helps if I attach the file...

  12. cracker_saba
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    Dear ChrisJordan, I have figured your problem out. The main problem of your code was that you did type a command during the execution of a command. You cannot give command during the execution of another command. When you typed >>>print raw_input('What is you date of birth?") that means your program is expecting a value to set in a variable not defined and here in the place of a value you can not call a function as it would take the function calling command as a string value of a non defined variable.Thus in the next line x has no value assigned,even it doesn't really exist and it gives a error saying x is not defined.You should try writing the following code in the first line of your program which will definitely work >>>x=raw_input("What is your date of birth?\t") remember that you can't use the print method here.But later you can write code like >>>print x My English is not good so thank you very much for reading this comment hope it will help you out.

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

    Okay, I think I figured out Problem Set 0 out. Can one of you kind people please take a look at the attached file, let me know if this is correct and sufficient to complete the assignment?

    1 Attachment
  14. ChrisJordan
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ahh! Imagine that is what it is except add the word "birth" in lol!

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