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.

6 years ago*

Comment has been collapsed.

Reserved

6 years ago
Permalink

Comment has been collapsed.

Sorry can't help you with Python. Perhaps paste the problem code in here?

6 years ago
Permalink

Comment has been collapsed.

I honestly have no idea what you're talking about but have a bump for visibility :)

6 years ago
Permalink

Comment has been collapsed.

Paste the problem code on your gists (github) or pastebin. Maybe i could help little

6 years ago
Permalink

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.

6 years ago
Permalink

Comment has been collapsed.

Sorry, but I can't code for shit ;-;.

6 years ago
Permalink

Comment has been collapsed.

View attached image.
6 years ago
Permalink

Comment has been collapsed.

Let me know what the task is and what the problem is, I can't offer any promises, but I'll see what I can do.

6 years ago
Permalink

Comment has been collapsed.

I don't know anything about programming, good luck though. :)
Thanks for the GA.

6 years ago
Permalink

Comment has been collapsed.

bump

6 years ago
Permalink

Comment has been collapsed.

Best I can do is offer a book on Python that I haven't read.

6 years ago
Permalink

Comment has been collapsed.

Bump

6 years ago
Permalink

Comment has been collapsed.

Sorry can't help you with Python
butthanks for the wishlisted giveaway :o)

6 years ago
Permalink

Comment has been collapsed.

bump

6 years ago
Permalink

Comment has been collapsed.

what's the problem? please don't add me.

6 years ago
Permalink

Comment has been collapsed.

Already added above

6 years ago
Permalink

Comment has been collapsed.

i think you need to use type()

https://stackoverflow.com/a/152596

6 years ago
Permalink

Comment has been collapsed.

or use a list of digits and check the input against the list...

6 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 3 years ago.

6 years ago
Permalink

Comment has been collapsed.

bmp

6 years ago
Permalink

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

6 years ago*
Permalink

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.

6 years ago*
Permalink

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?

6 years ago
Permalink

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

6 years ago
Permalink

Comment has been collapsed.

import msvcrt
while True:
if msvcrt.kbhit():
key = msvcrt.getch()

6 years ago
Permalink

Comment has been collapsed.

you need only one thing for programing, learn to google https://stackoverflow.com/questions/24072790/detect-key-press-in-python

6 years ago
Permalink

Comment has been collapsed.

GoatPimp out

6 years ago
Permalink

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.

6 years ago
Permalink

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 ?

6 years ago
Permalink

Comment has been collapsed.

Bump

6 years ago
Permalink

Comment has been collapsed.

Thank you for your giveaway, TLM! :-)

Sorry that I can't help you because the only python I know are these. ;-)

6 years ago
Permalink

Comment has been collapsed.

bump

6 years ago
Permalink

Comment has been collapsed.

I would love to help you... but unfortunately, I know absolutely nothing about python or anything similar x.x Hope someone else can help you solve this problem ._.

6 years ago
Permalink

Comment has been collapsed.

Deleted

This comment was deleted 2 years ago.

6 years ago
Permalink

Comment has been collapsed.

Sign in through Steam to add a comment.