I honestly have no idea what you're talking about but have a bump for visibility :)
Comment has been collapsed.
Paste the problem code on your gists (github) or pastebin. Maybe i could help little
Comment has been collapsed.
Hey I think I'm just going to add you to my friends list, because I know how to do the rest of the assignment, I would but my comp science department checks for copied code, and I don't really want to be called in for cheating.
Comment has been collapsed.
I don't know anything about programming, good luck though. :)
Thanks for the GA.
Comment has been collapsed.
Best I can do is offer a book on Python that I haven't read.
Comment has been collapsed.
I dont understand python because i dont know it but let me tell you how i will try to tackle this.
you have a string named user_input
when the user presses a key you check if the input is a digit (number)
if it is you add it to your string
(else you ignore it)
in any language it would go like this
user_input = key_pressed
if number_check(user_input) = true { string_of_digits = string_of_digits & user_input}
/edit: added a small example
Comment has been collapsed.
Here you go:
test = input("Enter some value: ")
if test.isdigit() == True:
val = int(test)
print ("result is: " + str(val**2))
else:
print ("You phail")
I guess there should be some gui, but have no idea what are you using and what's the 'text' function to display with.
Obviously, if you need to gather only digits from random user input, then you should loop input reading with sys.stdin.read or whatever you're using checking value for being a digit and appending to resulting string, then convert to integer and do the math.
Comment has been collapsed.
This is the part I'm having a problem with:
Which part of that, specifically? Capturing the input, parsing it, concatenating it to the string, or converting the string to a number?
Comment has been collapsed.
Capturing the input, really. I'm currently using processing, at this moment, I know how to do the math part, the actually converting the number to the square root, my problem is I don't know how to get my variable which I labeled digit_string to be a string of numbers, because basically last program that I wrote was a simple key counter and I understood that. My thing is instead of a key counter, I need everywhere under def keypressed to add a string of digits that will appear under the def draw, I have all that the issue is I just don't know what I'm missing to have it be any key pressed, teacher doesn't care if I do an error check because we haven't learned how to do that yet. Basically I want to be able to press the number keys any number key, and have it add to the string and appear as 42 or 35, or 87 or 545454444646 if I so choose, under text.
key_counter = 0.0
def setup () :
size (400, 400)
background (0)
textSize (25)
def draw ():
global key_counter
background (0)
text ("Key pressed " + str(key_counter), 20, 30)
def keyPressed ():
global key_counter
key_counter = 1 + key_counter
Comment has been collapsed.
you need only one thing for programing, learn to google https://stackoverflow.com/questions/24072790/detect-key-press-in-python
Comment has been collapsed.
I did google it, unfortunately I'm using processing and I can't really apply that with what I know/learned the thing is we haven't learned it and I'm still trying to figure it out. That doesn't help me.
Comment has been collapsed.
Can't you just check the user input (since it's a key/a char, not sequence of char) and ignore it to your string if it's not number ?
Comment has been collapsed.
29 Comments - Last post 2 hours ago by adam1224
7 Comments - Last post 3 hours ago by xXSAFOXx
16,297 Comments - Last post 5 hours ago by SebastianCrenshaw
52 Comments - Last post 6 hours ago by adam1224
206 Comments - Last post 9 hours ago by Joey2741
31 Comments - Last post 10 hours ago by Pika8
1,519 Comments - Last post 11 hours ago by Tristar
7,976 Comments - Last post 60 seconds ago by herbesdeprovence
104 Comments - Last post 4 minutes ago by Axelflox
42 Comments - Last post 22 minutes ago by Gelweo
726 Comments - Last post 27 minutes ago by stlpaul
23 Comments - Last post 31 minutes ago by FateOfOne
12 Comments - Last post 1 hour ago by Mikalye
43 Comments - Last post 1 hour ago by Vincer
Hey, basically I'm just looking for people who understand python, and can help me with some comp science homework, I'm sort of stuck, and normally I'm good at figuring it out on my own but this assignment is just wrecking me, and it's supposed to be "easy" I can figure out the hard shit but this string shit is killing me, I just want to know why and understand how it works right now so if you don't mind helping me out that would be awesome, I'm using processing, because I'm in beginner computer science, and that's what they use.
giveaway: https://www.steamgifts.com/giveaway/zigEF/neko-nin-exheart
By the way you're all free to enter, I don't really care one way or another, I just was hoping that someone would see it who had a comp science background and wouldn't mind me pestering them with a few questions.
Edit again: This is the problem I'm having trouble with:
First the assignment: For this question, you will write a program that allows the user to type in a number on the keyboard. When the user clicks the mouse, the program will calculate and display the square of the number that was typed in (e.g. if the user types in the number 12, then when the mouse is clicked, your program will display the value 144, i.e. 122).
This is the part I'm having a problem with:
When the user presses a key: Add any key that the user types to your string of digits. If the user presses a key that is not a digit, itโs okay if your program crashes (adding error-checking is beyond the scope of this question). Always display the current digits that the user has typed in using the text() function.
Comment has been collapsed.