Oct-16-2021, 09:41 AM
Hi,
My son is is having issues with the below homework.
For a temporary wifi system at an event:
- Enter number of Access Points (AP):
- Enter the signal strength (0-100) for each access point.
- Convert signal strength input to Strong (S), Medium (M), Poor (P)
- Output a string with the conversions (e.g, for 5 APs, a possible output would show as "SMMPS".
He wrote the below code, but it is only outputting the conversion of the last signal entered. This is frustrating for him as his last homework for a program to calculate a students grade based on marks had the same issue. For that homework his teacher mentioned a possible issue with his indentation?!?!
Any help would be appreciated. I am newer than my son at this!
Thanks, Iain
How many locations at this site?
5
Enter location name:
1
Enter signal strength:
45
Enter location name:
2
Enter signal strength:
45
Enter location name:
3
Enter signal strength:
78
Enter location name:
4
Enter signal strength:
99
Enter location name:
5
Enter signal strength:
87
S
** Process exited - Return Code: 0 **
Press Enter to exit terminal[/i]
My son is is having issues with the below homework.
For a temporary wifi system at an event:
- Enter number of Access Points (AP):
- Enter the signal strength (0-100) for each access point.
- Convert signal strength input to Strong (S), Medium (M), Poor (P)
- Output a string with the conversions (e.g, for 5 APs, a possible output would show as "SMMPS".
He wrote the below code, but it is only outputting the conversion of the last signal entered. This is frustrating for him as his last homework for a program to calculate a students grade based on marks had the same issue. For that homework his teacher mentioned a possible issue with his indentation?!?!
Any help would be appreciated. I am newer than my son at this!
Thanks, Iain
signal_array = [] locations_array = [] signal_d = [] #inputs locations = int(input("How many locations at this site?")) for i in range(locations): locations_array.append (input("Enter location name: ")) signal = float(input("Enter signal strength: ")) #validation while signal < 0 or signal >100: print("Enter a valid signal strength (0-100)") signal = float(input("Enter signal strength: ")) signal_array.append(signal) #conversion for i in (signal_array): if signal > 80: grade = 'S' elif signal < 30: grade = 'P' else: grade = 'M' signal_d.append(grade) #output for i in (signal_d): print() print (i, end="")Output was as follows:
How many locations at this site?
5
Enter location name:
1
Enter signal strength:
45
Enter location name:
2
Enter signal strength:
45
Enter location name:
3
Enter signal strength:
78
Enter location name:
4
Enter signal strength:
99
Enter location name:
5
Enter signal strength:
87
S
** Process exited - Return Code: 0 **
Press Enter to exit terminal[/i]