Let Mn = 2n 1 be the n th Mersenne number. Show that Mn can be…

Question Answered step-by-step Let Mn = 2n 1 be the n th Mersenne number. Show that Mn can be… Let Mn = 2n ? 1 be the n th Mersenne number. Show that Mn can be prime only if n is. [5 marks] Let ?m = m(m + 1)/2 be the mth triangular number and recall that a perfect number is one equal to the sum of its factors (including 1 but excluding the number itself). Suppose that p = Mn is prime. Show that ?p is a perfect number. [5 marks] The result of the program should be a list of all movies rated with the following information per line — movie id, movie title, release date, IMDB URL, average rating, total number of unique users rated, total number of ratings for the movie Use 2 reducers by setting the number of reducers to 2. Please add combiner for efficiency. Define a custom counter that has a running count of total records processed in map, total number of unique movies in reducer. Before you begin, please split the input file into 5 files called u1.data, u2.data, u3.data, u4.data and u5.data, each having 20000 records. Use the Unix split command. Reference: https://kb.iu.edu/d/afarAll the input files – 5 user ratings file and the movie information file should be gzip compressed before processing. Reducer output files should be gzipped.I am getting below-mentioned error which is running code to the simulation of a smart home using Python codes and using MQQT as a message broker in the background.Its code to simulate AC device ,Light dvice  and Edgeserver code, and main code contains calling functions for the child codes. +++++++++++++++++++++++++++++++++++++++++++++++++++++++Error While Running Main.pyC:UsersRiyanshDownloadsIITM_CourseIOT_ProjectC03-Project-01-Simple-Smart-HomeSoluitonvenvScriptspython.exe C:/Users/Riyansh/Downloads/IITM_Course/IOT_Project/C03-Project-01-Simple-Smart-Home/Soluiton/main.pySmart Home Simulation started.*********************Intitate the device creation and registration process.Creating the Light devices for their respective rooms.Traceback (most recent call last):File “C:UsersRiyanshDownloadsIITM_CourseIOT_ProjectC03-Project-01-Simple-Smart-HomeSoluitonmain.py”, line 21, in light_device_1 = Light_Device(“light_1”, “Kitchen”)File “C:UsersRiyanshDownloadsIITM_CourseIOT_ProjectC03-Project-01-Simple-Smart-HomeSoluitonLightDevice.py”, line 24, in _init_self.client.on_disconnect = self._on_disconnectAttributeError: ‘Light_Device’ object has no attribute ‘_on_disconnect’Process finished with exit code 1+++++++++++++++++++++++++++++++++++++++++++++++++++++++ I have copied allthe codes in the below section .Thanks in advance. ###########################Main.py  – Start######################import timefrom EdgeServer import Edge_Serverfrom LightDevice import Light_Devicefrom ACDevice import AC_DeviceWAIT_TIME = 0.25  print(“Smart Home Simulation started.”)# Creating the edge-server for the communication with the userdef callback(n):print(“Main: “, n)edge_server_1 = Edge_Server(‘edge_server_1′,callback)time.sleep(WAIT_TIME)# Creating the light_deviceprint(“n***********************” )print(“Intitate the device creation and registration process. n” )print(“Creating the Light devices for their respective rooms.”)light_device_1 = Light_Device(“light_1”, “Kitchen”)time.sleep(WAIT_TIME)  light_device_2 = Light_Device(“light_2”, “Kitchen”)time.sleep(WAIT_TIME)  # Creating the ac_device  print(“n***********************” )print(“Creating the AC devices for their respective rooms. “)ac_device_1 = AC_Device(“ac_1”, “BR1”)ac_device_2 = AC_Device(“ac_2”, “Kitchen”)time.sleep(WAIT_TIME)  print(“n***********************” )print(“Get status of all devices.”)edge_server_1.get_status(“all”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Updating light_1 light_intensity to HIGH.”)edge_server_1.set(“light_1″,”light_intensity”,”HIGH”)time.sleep(WAIT_TIME)  print(“n***********************” )print(“Get status of all lights.”)edge_server_1.get_status(“LIGHT”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Updating Ac_1 temperature to 18”)edge_server_1.set(“ac_1″,”temperature”,18)time.sleep(WAIT_TIME)  print(“n***********************” )print(“Update switch status to ON for everything in Kitchen.”)edge_server_1.set(“Kitchen”,’switch_state’,’ON’)time.sleep(WAIT_TIME)print(“n***********************” )print(“Get status of all devices.”)edge_server_1.get_status(“all”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Get status of devices in kitchen.”)edge_server_1.get_status(“Kitchen”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Get status of devices in BR1.”)edge_server_1.get_status(“BR1”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Get status of all AC.”)edge_server_1.get_status(“AC”)time.sleep(WAIT_TIME)print(“n***********************” )print(“Smart Home Simulation stopped.”)edge_server_1.terminate()###########################Main.py – End #################################################LightDevice.py – Start ####################import jsonimport paho.mqtt.client as mqttimport paho.mqtt.publish as publishHOST = “localhost”PORT = 1883class Light_Device():# setting up the intensity choices for Smart Light Bulb_INTENSITY = [“LOW”, “HIGH”, “MEDIUM”, “OFF”]def _init_(self, device_id, room):   # Assigning device level information for each of the devices.   self._device_id = device_id   self._room_type = room   self._light_intensity = self._INTENSITY[0]   self._device_type = “LIGHT”   self._device_registration_flag = False   self.client = mqtt.Client(self._device_id)   self.client.on_connect = self._on_connect   self.client.on_message = self._on_message   self.client.on_disconnect = self._on_disconnect   self.client.connect(HOST, PORT, keepalive=60)   self.client.loop_start()   self._register_device(self._device_id, self._room_type, self._device_type)   self._switch_status = “OFF”def _register_device(self, device_id, room_type, device_type):   request = {“type”: “register”, “flag”: “SYN”, “device_id”: device_id, “room_type”: room_type,              “device_type”: device_type}   topic_name = “home”   publish.single(topic=topic_name, payload=json.dumps(request), hostname=HOST)# Connect method to subscribe to various topics.def _on_connect(self, client, userdata, flags, result_code):   client.subscribe(self._device_id, 0)   client.subscribe(self._device_type, 0)   client.subscribe(self._room_type, 0)   client.subscribe(self._room_type + “/” + self._device_type, 0)   client.subscribe(“all”, 0)# method to process the recieved messages and publish them on relevant topics# this method can also be used to take the action based on received commandsdef _on_message(self, client, userdata, msg):   reqString = “Light Device – ” + self._device_id + ” : ” + str(msg.payload)   print(reqString)   request = json.loads(msg.payload)   if request[‘type’] == ‘set’:       if request[‘flag’] == ‘switch_state’:           self._set_switch_status(request[‘value’])       if request[‘flag’] == ‘light_intensity’:           self._set_light_intensity(request[‘value’])       response = {“type”: “set”, “status”: 0, “device_id”: self._device_id}       topic_name = “home”       publish.single(topic=topic_name, payload=json.dumps(response), hostname=HOST)   if request[‘type’] == ‘status’:       self.get_status()# Getting the current switch status of devicesdef _get_switch_status(self):   return self._switch_status# Setting the the switch of devicesdef _set_switch_status(self, switch_state):   self._switch_status = switch_state# Getting the light intensity for the devicesdef _get_light_intensity(self):   return self._light_intensity# Setting the light intensity for devicesdef _set_light_intensity(self, light_intensity):   self._light_intensity = light_intensity###########################LightDevice.py – End #################################################EdgeServer.py – Start ######################import jsonimport timeimport paho.mqtt.client as mqttimport paho.mqtt.publish as publishHOST = “localhost”PORT = 1883     WAIT_TIME = 0.25  class Edge_Server:def _init_(self, instance_name, callBack):      self._instance_id = instance_name   self.client = mqtt.Client(self._instance_id)   self.client.on_connect = self._on_connect   self.client.on_message = self._on_message   self.client.connect(HOST, PORT, keepalive=60)   self.client.loop_start()   self._registered_list = []   self.callBack = callBack# Terminating the MQTT broker and stopping the executiondef terminate(self):   self.client.disconnect()   self.client.loop_stop()# Connect method to subscribe to various topics.     def _on_connect(self, client, userdata, flags, result_code):   client.subscribe(“home/#”, 0)   # method to process the recieved messages and publish them on relevant topics # this method can also be used to take the action based on received commandsdef _on_message(self, client, userdata, msg):   print(“Edge server :” , msg.payload)   response = json.loads(msg.payload)           if response[‘type’] == ‘register’:       topic_name = response[‘device_id’]       response[‘flag’]=’ACK’       self._registered_list.append(response[‘device_id’])       publish.single(topic=topic_name, payload=json.dumps(response), hostname=HOST)      if response[‘type’] == “set” and response[‘status’] == 0:       topic_name = response[‘device_id’]       request = {“type”: “status”}       publish.single(topic=topic_name, payload=json.dumps(request), hostname=HOST)          if response[‘type’] == “status”:       self.callBack(msg.payload)       # Returning the current registered listdef get_registered_device_list(self):   return self._registered_list# Getting the status for the connected devicesdef get_status(self,topic_name):   request = {“type”: “status”}   publish.single(topic=topic_name, payload=json.dumps(request), hostname=HOST)# Controlling and performing the operations on the devices# based on the request receiveddef set(self, topic_name, command, value):   request = {“type”: “set”, “flag”:command, “value”:value }   publish.single(topic=topic_name, payload=json.dumps(request), hostname=HOST)###########################EdgeServer.py- End #################################################ACDevice.py – Start######################import jsonimport paho.mqtt.client as mqttimport paho.mqtt.publish as publishHOST = “localhost”PORT = 1883class AC_Device():_MIN_TEMP = 18  _MAX_TEMP = 32  def _init_(self, device_id, room):   self._device_id = device_id   self._room_type = room   self._temperature = 22   self._device_type = “AC”   self._device_registration_flag = False   self.client = mqtt.Client(self._device_id)     self.client.on_connect = self._on_connect     self.client.on_message = self._on_message     self.client.on_disconnect = self._on_disconnect     self.client.connect(HOST, PORT, keepalive=60)     self.client.loop_start()     self._register_device(self._device_id, self._room_type, self._device_type)   self._switch_status = “OFF”# calling registration method to register the devicedef _register_device(self, device_id, room_type, device_type):   request = {“type”:”register”, “flag”:”SYN”, “device_id”: device_id, “room_type”: room_type, “device_type”:device_type }   topic_name = “home”   publish.single(topic=topic_name, payload=json.dumps(request), hostname=HOST)# Connect method to subscribe to various topics. def _on_connect(self, client, userdata, flags, result_code):   client.subscribe(self._device_id, 0)   client.subscribe(self._device_type, 0)   client.subscribe(self._room_type, 0)   client.subscribe(self._room_type+”/”+self._device_type, 0)   client.subscribe(“all”, 0)# method to process the recieved messages and publish them on relevant topics # this method can also be used to take the action based on received commandsdef _on_message(self, client, userdata, msg):    reqString = “AC Device – ” + self._device_id + ” : ” + str(msg.payload)   print(reqString)   request = json.loads(msg.payload)      if request[‘type’] == ‘set’:       if request[‘flag’] == ‘switch_state’:           self._set_switch_status(request[‘value’])       if request[‘flag’] == ‘temperature’:           self._set_temperature(request[‘value’])              response = {“type”:”set”, “status”: 0, “device_id”: self._device_id}       topic_name = “home”       publish.single(topic=topic_name, payload=json.dumps(response), hostname=HOST)              if request[‘type’] == ‘status’:       self.get_status()# Getting the current switch status of devices def _get_switch_status(self):   return self._switch_status# Setting the the switch of devicesdef _set_switch_status(self, switch_state):   self._switch_status = switch_state# Getting the temperature for the devicesdef _get_temperature(self):   return self._temperature        # Setting up the temperature of the devicesdef _set_temperature(self, temperature):   self._temperature = temperature###########################ACDevice.py – End ######################les. I work as a project manager for a large pharmaceutical company at the moment, but before then I had a skincare company and also a certification company that I set up, and prior to that I used to work at the University of Leeds as a social scientist, and that’s where I did my PhD. And prior to that I used to work for a large pharmaceutical company in the north of England, developing lots of different formulations, like tablets, capsules, injectables. I was born in Pakistan, in Islamabad, and I was brought up by my grandparents, maternal grandparents, and an orderly, who used to follow my brother and I around. I had a fairly interesting childhood. I was a bit of a tomboy, wasn’t into dolls but more into climbing trees and playing baseball and cricket and riding bikes, and I was into science fiction. My favourite TV programme was Star Trek and I remember doing lots of role-plays with my little brother and other little neighbourhood boys. We had this – this neighbour boy and he was slightly oriental looking so he made the perfect Mr Spock. I just – I got – I remember getting some – my mum’s eyeliner and drawing his eyebrows on. And my brother was Bones and I was Captain Kirk, of course. And we had this remote-controlled car, my favourite remote-controlled car, and we used the receivers – controls for that as receivers for Mr Spock and – and Captain Kirk. I feel a bit like a citizen of the world, having – being of Afghan origin and then going to school in Pakistan, primary school. That was an interesting experience. I – I had a – I spoke Urdu with a very different accent so I used to get laughed at and picked at at school and being called a foreigner. And then I moved to England, again, same story; used to get picked on sometimes for having a different accent, not being able to speak English with a Yorkshire accent. So it’s – it’s been an interesting experience, experiencing I suppose you could call it racism in a way but from both sides of the – the world. So I always felt as if I didn’t belong and I suppose my way of making sense of that was to – at school, hanging around with – with bikers and rockers and people with – I had my first motorbike when I was – when I was still at school, about sixteen, and had a – a biker’s jacket and biker boots and used to listen to rock music, and that kind of carried on into university. When I went to university I had this identity of a biker chick and made friends quite easily with – with the local sort of crowd. And I always felt safe – safe with that crowd, maybe ’cause they were marginalised and I felt I could relate to that group. I did my degree in pharmacology at Sunderland University and we had about roughly fifty percent girls and boys on the course, but it was quite a – a shock when I actually went out to industry and my first job was as a polyurethane chemist and I was the only female there. And then after that the pharmaceutical company, which was like a proper GMP environment, I worked in there making tablets. And again, I was the only female in the whole sort of product development department, and I just remember having a hoot of a time with all my male colleagues. And – and I remember once getting in this machine, a big granulator, to clean it from the inside, ’cause I was the smallest person there. So then I moved onto academia and that was in Leeds University and it was very different, ’cause I was used to hardcore science and then I move into a qualitative research sort of softer science, where you interview people. And it allowed me to write papers. I’ve written about ten papers, nine of those as first author and I got them published in really good journals, including the BMJ. And the findings of my PhD, they were changed into a public health policy. So that was great, I felt as though I really made a difference, not just personally but also to – to the society. And then I fell pregnant with twins and the girls were premature. They’re fine now. They were six weeks premature. And it was decision time, you know. I can’t really put them in a crèche because the university salaries aren’t that good, or weren’t that good at the time. So I decided to start a business from home so I could spend time with them and I thought I’d use my skills from my pharmaceutical development days and started to make creams in my kitchen. And it was just a – a matter of using my scientific experience and analytical mind to put those together and make something that was fun, but it turned out – just happened into something that could make me – earn me a living while I looked after my children. Initially the cream making, I was giving these away as – you know, just as Christmas gifts or – or birthday presents, or if somebody needed it just as a free – freebie, but it reached a point where I couldn’t really – you know, they were quite expensive, and I had to start charging money because I was getting emails from around the world asking for these creams. At that point I went to see an accountant and decided to set a business up as a limited company so I could charge money and – and buy, you know, borrow some money from the bank so I can pay and – and basically make the whole thing more professional and – and commercial. By the time I sold the business, it was exporting to 14 countries. The brand was called Saaf Skincare. And the unique selling point was it was totally preservative free, ’cause it was all oils and I used beeswax as a base. So it was oil – preservative free. It was free from all nasty chemicals and it was organic, certified vegetarian, cruelty free certified and halal certified. I personally found science to be a lot of fun whatever I’ve done, whatever I’ve applied science to in my life. It’s – it’s about exploration. It’s like – about being, like, Captain Kirk, but instead of exploring different planets, there’s so much to explore here on, you know, on earth, and that’s the fascinating thing about science. And you can apply it to cooking, to makeup, to – to everything, you know, to cleaning, jewellery, your house, and the fact that it gives you tools to do so many different things and so many different aspects of science, as reflected by my own sort of personal career. It’s great fun. If I was born again, I’d be a scientist all over again.Kindly answer all the questions Computer Science Engineering & Technology C++ Programming MATHEMATIC TECH201 Share QuestionEmailCopy link Comments (0)