coding error on pyscripter

16 views
Skip to first unread message

b302...@my.shu.ac.uk

unread,
Oct 29, 2015, 6:31:30 PM10/29/15
to PyScripter
got this coding issue that i have to do for coursework, the final two lines of the code wont work and i cant see where to put other functions in to isolate all three inputted digits and replace them using the formula ((the sum of that digit plus 7) mondulo 10)
the code is.........

def main ():
    global unencrypted
    get_data()
    get_encryption()
    show_results()

def get_data():
    global input
    unencrypted=input("enter a 3 digit number")

def get_encryption():
    global input
    global recompose_original_number
    isoate_digits()
    replace_digits()
    swap_digit_1_with_digit_3()
    recompose_encrypted_number()

def show_results():
    global input
    global recompose_original_number
    print("recompose_original_output" unencrypted)
    print("encrypted:"encrypted)

main()

any help would be massively appreciated
thanks in advance

Andy Milne

unread,
Oct 29, 2015, 11:30:55 PM10/29/15
to pyscr...@googlegroups.com
There's a number of issues. The 1st issues to address would be some implementation of these missing functions:

    isoate_digits()
    replace_digits()
    swap_digit_1_with_digit_3()
    recompose_encrypted_number()

You might consider learning about parameters and returning values. E.g. Consider:

def get_data():
    global input
    unencrypted=input("enter a 3 digit number")
    return unencrypted 

def get_encryption(input):
    return encrypt_number(input)


If you used the above, then you can write:

def main ():
    unencrypted=get_data()
    encrypt = get_encryption(unencrypted )
    show_results(unencrypted, encrypt )

You could google for "Python string to int", it'll probably lead you to something like this:

for( ch in unencrypted):
    print((int(ch)+7)%10

Might need to subtract a int('0').

The above should encrypt the number, then google "Python int to string" to output the result.

Sorry if there's any typos above. I did this on my phone.

Have fun with Pyhon!

--
You received this message because you are subscribed to the Google Groups "PyScripter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyscripter+...@googlegroups.com.
To post to this group, send email to pyscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/pyscripter.
For more options, visit https://groups.google.com/d/optout.


--
Sent from Gmail Mobile
Reply all
Reply to author
Forward
0 new messages