Thread: How do I finalise this program

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] == bin_SN_0 and \

list_bin[user_SN] == bin_SN_1 and \

list_bin[user_SN] == bin_SN_2 and \

list_bin[user_SN] == bin_SN_3 and \

list_bin[user_SN] == bin_SN_4 and \

list_bin[user_SN] == bin_SN_5 and \
list_bin[user_SN] == 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

SN_1 = SN

SN_2 = SN

SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

SN_0 = SN

SN_1 = SN

SN_2 = SN

SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

SN_0 = SN

SN_1 = SN

SN_2 = SN

SN_3 = SN

SN_4 = SN
025
SN_5 = SN

SN_6 = SN

SN_0 = SN

SN_1 = SN

SN_2 = SN
SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

SN_0 = SN

SN_1 = SN
038
SN_2 = SN
039
SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

SN_0= SN

SN_1 = SN

SN_2 = SN

SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

SN_0 = SN

SN_1 = SN

SN_2 = SN

SN_3 = SN

SN_4 = SN

SN_5 = SN

SN_6 = SN

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

bin_SN_0 = list_bin[SN]

bin_SN_1 = list_bin[SN]

bin_SN_2 = list_bin[SN]

bin_SN_3 = list_bin[SN]

bin_SN_4 = list_bin[SN]

bin_SN_5 = list_bin[SN]

bin_SN_6 = list_bin[SN]

user_SN = str(input("Enter your student ID: "))```
2. No Profile Picture
Contributing User
Devshed Novice (500 - 999 posts)

Join Date
May 2009
Posts
667
Rep Power
41
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