Task1.py and task3.py works properly even though I did what asked in instruction but can't pass the gradebot

Your final (after you have tested that it works properly) program MUST contain the get_highest_lowest function, but MUST NOT contain any call to this function.

How I am suppose to make script work without calling the function ? Also I have tried to copy and paste solution that I found on this forum but It didn’t work also since it doesn’t call the func that created. Can you help me please ? Have a great day!! [Task 1 and Task 3 codes are below]

TASK 1 :

from robot_control_class import RobotControl

def get_highest_lowest():
    rc = RobotControl()
    l = rc.get_laser_full()
    maxi = l[0]
    mini = l[0]
    for i in range(0, len(l)):
        if i > maxi:
            maxi = i
        if i < mini:
            mini = i
    return print(maxi, mini)



import math
from robot_control_class import RobotControl

class ExamControl():
    def __init__(self):
        self.rc = RobotControl(robot_name="turtlebot")

    def get_laser_readings(self):
        return self.rc.get_laser_full() # burada direkt okuma yaptırdım

    def main(self):
        self.rc.move_straight() # ilk başta düz git
        while 1:
            listx = self.get_laser_readings() # giderken okuma yap sağdan soldan
            print(listx[0], listx[1]) # ilk değer sol ikinci değer sağ taraf
            if listx[0] == math.inf or listx[1] == math.inf: # inf'e ulaştığında 
                self.rc.stop_robot() # dur

move1 = ExamControl()

HI @fkaan ,

Because the function is called by the Gradebot, therefore you do not have to explicitly call it.

There are some issues in your code:


  1. By doing i > maxi and i < mini you are actually checking the index value to maxi or mini - This is wrong. You need to check the value at this index if it is maximum or minimum.
  2. You have not accounted for the constraint here - do not account for “inf” values - your current code will return inf values if you do not use proper if conditions.
  3. You must return the max and min indexes. - you are printing them on return which will not work.


  1. You just need to complete the class functions.
  2. We do not use while 1 in python. It is not the convention, we use while True instead.
  3. Remove the last two lines where you call the main function
move1 = ExamControl()   # remove this line
move1.main()            # remove this line

You need to rework both your codes, your current codes will not work for TASK 1 and 3.

Fix the problems and you should be fine. Read the question twice or more before you answer it. You seem to have not understood the question in both the tasks properly.



Hi again thanks for your response I have passed the test. But it seem it hasn’t appear on my accomplishment. Do I need to do something extra ?

Hi @fkaan ,

It would normally take up to 2 working days for the certificate to show up. Please be patient.
In case it takes more than 2 days, you can then report the same at this email: info(at)theconstructsim(dot)com.


1 Like

dear @girishkumar.kannan
i have accounted for the constraint here and i also checked by arraigning the laser data in ascending and descending order to find the corresponding position value, which this code find correctly but while submitting the code i get a 0

from robot_control_class import RobotControl

def get_highest_lowest():
            # Create an instance of the RobotControl class
            robot_control_instance = RobotControl()

            # Get all the values of the laser readings and store them in a list
            laser_values = list(robot_control_instance.get_laser_full())
            #print (laser_values)
            if not laser_values:
            # If there are no values, return None for both positions
                return None, None

        # Exclude infinity values from consideration when finding the positions
            filtered_values = [value for value in laser_values if isinstance(value, (int, float)) and value != float('inf')]

            if not filtered_values:
            # If there are no numeric values, return None for both positions
                return None, None
            highest_position = laser_values.index(max(filtered_values))
            lowest_position = laser_values.index(min(filtered_values))

            print (highest_position)
            print (lowest_position)

Hi @tabrar,

I think you are asked to return the values, right?

I see in this function you are just printing values, but returning nothing.