Posts: 5
Threads: 3
Joined: Feb 2017
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:
- A digit,
- An uppercase letter,
- A lowercase letter, or
- A 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.
Posts: 4,220
Threads: 97
Joined: Sep 2016
(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?
Posts: 5
Threads: 3
Joined: Feb 2017
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!
Posts: 687
Threads: 37
Joined: Sep 2016
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
Posts: 31
Threads: 6
Joined: Feb 2017
Feb-08-2017, 10:29 AM
(This post was last modified: Feb-08-2017, 10:32 AM by tannishpage.)
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.
Posts: 12,031
Threads: 485
Joined: Sep 2016
Feb-08-2017, 06:47 PM
(This post was last modified: Feb-08-2017, 06:48 PM by Larz60+.)
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)
Posts: 3,458
Threads: 101
Joined: Sep 2016
(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")
Posts: 687
Threads: 37
Joined: Sep 2016
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
|