Python Forum
Need Help with writing this code!?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need Help with writing this code!?
#1
I am in a computer science course at college, and I am so new to this that even reading the chapters, and watching youtube videos does not help me. I have an assignment due this week that I have no idea how to even begin... if anyone could help me out it would be greatly appreciated. Thank you so much

The first assignment is:

  • Write a program that asks the user to enter a character, and based on its ASCII value the program determines whether this character is:
    • digit,
    • An uppercase letter,
    • lowercase letter, or
    • symbol
The second assignment is:
  • This is a little game in which the user "throws" a single virtual "dart" at a board containing three circles that appear at random locations. Write a program that draws three circles of radius 50 at random locations, and asks the coordinates of a point, the dart
    The program reports the number of points earned based on where the dart fell:

    • 1000 points if the dart fell inside the overlap of all three circles,
    • 500 points if the dart fell inside the overlap of only two of the circles,
    • 100 points if the dart fell inside only one of the circles,
    • 0 points if the dart did not hit any of the circles.

 


Reply
#2
(Feb-06-2017, 08:36 PM)r6lay Wrote: I have an assignment due this week that I have no idea how to even begin.

Well, that's a problem. We don't do people's assignments for them. We help people do their assignments when they run into problems.

Given what you've stated, you need to think about the following things:
  • How do you ask the user for input?
  • How do you get the ASCII value of a character?
  • How can you use a value to make different choices?
  • How do you draw a circle?
  • How do you tell if a point is in a circle or not?
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
I understand, I didn't mean for anyone to do it for me but I don't even know where to begin, but thank you thats very helpful!
Reply
#4
Start small.
  • Write a program that gets a character
  • Enhance it to get the ASCII value
  • Enhance it to compare it with some ranges of values
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#5
Um. I don't know how the circle one might work but i might be able to help with the ascii conversion.

Steps:
1.)Ask user input eg:
input("Enter something: ")
2.)Look up on the internet the ascii conversions. Store them in a dictionary. (Look up how dictionaries work.)
3.)Now write a print statement that prints out the key for the item.

Reply for more help.

If that is not what you are looking for than well good luck.
Reply
#6
If you just need to pass this course as a requirement and have no interest in learning
about programming, stop reading now.

If on the other hand, you'd like to learn about ASCII, how it came about and is structured
the way that it is, and how programmatically you can categorize an ASCII character you can
start with this article: https://en.wikipedia.org/wiki/ASCII.

From this, you can see why any character < '00100000' binary (and also == 01111111) are control
characters (and not printable). Using a pattern of masks, you can programmatically determine the
the answer to
Quote:How can you use a value to make different choices?
assuming (value = ASCII value)
Reply
#7
(Feb-06-2017, 09:09 PM)r6lay Wrote: I understand, I didn't mean for anyone to do it for me but I don't even know where to begin, but thank you thats very helpful!

character = input("give me a character, yo! ")

# now do things, depending on what that character is
# for example...

if character.isdigit():
    print("That's a number, dude")
Reply
#8
1) is quite simple if you consider that you are just writing all numbers from 0 to 9999 (range(10000), in Python) in base 26 using a...z as digits.

2) depends a bit on what is meant by "draw". If it means "pick at random", then you are just picking 3 pairs of coordinates at random. Then given the user input, you can test if the distance between the user's coordinates and each of the three points is less that 50 and increment a counter if yes. Then from the final contents of the counter you can assign the final score.
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I need help writing this code for string properties and methods hannah71605 4 3,059 Mar-22-2021, 12:36 PM
Last Post: menator01
  Need help in Code for Writing View Functions in Flask - Python Web Framework ashishsme14 2 2,976 May-22-2020, 03:43 AM
Last Post: snippsat
  HELP - Writing code returning True or False Kokuzuma 2 2,759 Nov-01-2018, 03:37 AM
Last Post: Kokuzuma
  Speed of progress of writing code Johno 2 2,844 Jan-19-2018, 01:56 AM
Last Post: dwiga
  Problem writing code with my pseudocode MattWilk97 1 2,844 Aug-29-2017, 01:54 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020