#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2016
    Posts
    1
    Rep Power
    0

    How do I finalise this program


    I created a program with the following requirements however I'm not sure how can I add the loop, does it need to be after each variable. I have created 7 variables which hold the 4bit binary values. Example: bin_SN_0 = list_bin[SN_0] and done this 6 times.I repeat the same process of creating 14 more variables.

    here are the requriments 1. Receive student number via user input 2. Convert student number to 4 bit binary numbers (each digit within the student number will need to be converted). Example:

    student_number = "1127530"
    student_number_first = "0001"
    student_number_second = "0001"
    student_number_third = "0010"
    etc

    The algorithm you choose to convert the student number is up to you.

    Compare each 4 bit binary number using conditional statements (if statements) to YOUR specific student number binary code 3. If all binary numbers are correct and match YOUR student number binary conversion, a green LED light will turn on, if it doesn't match, a red LED light will turn on.

    this is my if statement do I repreat it for the following variables. this is my if statement.


    Code:
    if len(SN) != 7:
    
            print ("Red light")
    
        else:
    
            if list_bin[user_SN[0]] == bin_SN_0 and \
    
                list_bin[user_SN[1]] == bin_SN_1 and \
    
                list_bin[user_SN[2]] == bin_SN_2 and \
    
                list_bin[user_SN[3]] == bin_SN_3 and \
    
                list_bin[user_SN[4]] == bin_SN_4 and \
    
                list_bin[user_SN[5]] == bin_SN_5 and \
                list_bin[user_SN[6]] == bin_SN_6:
    
    
                print ("Green light")



    Code:
    list_bin = {"0":"0000","1":"0001","2":"0010","3":"0011","4":"0100","5":"0101","6":"0110","7":"0111","8":"1000","9":"1001"}
    
    SN = "1514812"
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    025
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    038
    SN_2 = SN[2]
    039
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0= SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    SN_0 = SN[0]
    
    SN_1 = SN[1]
    
    SN_2 = SN[2]
    
    SN_3 = SN[3]
    
    SN_4 = SN[4]
    
    SN_5 = SN[5]
    
    SN_6 = SN[6]
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
     
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
     
    
    bin_SN_0 = list_bin[SN[0]]
    
    bin_SN_1 = list_bin[SN[1]]
    
    bin_SN_2 = list_bin[SN[2]]
    
    bin_SN_3 = list_bin[SN[3]]
    
    bin_SN_4 = list_bin[SN[4]]
    
    bin_SN_5 = list_bin[SN[5]]
    
    bin_SN_6 = list_bin[SN[6]]
    
     
    
    user_SN = str(input("Enter your student ID: "))
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2009
    Posts
    652
    Rep Power
    39
    Cross-posted and already answered at Need Help In Finalising This Program. - Python | Dream.In.Code Also cross-posted at python 3.x - Created a program - Stack Overflow

    Comments on this post

    • b49P23TIvg agrees : What a mess! Thank you for investigating.
    Last edited by dwblas; May 2nd, 2016 at 07:39 PM.

IMN logo majestic logo threadwatch logo seochat tools logo