+1 (315) 557-6473 

Create a Program to Create a Astro Webstore in Python Assignment Solution.


Instructions

Objective
Write a python assignment program to create a astro webstore.

Requirements and Specifications

program to create a astro webstore in python
program to create a astro webstore in python 1

Source Code

from OpticalToolbox import OpticalToolbox

from OTA import OTA

from EP import EP

from Mount import Mount

from Package import Package

def task_1(list_otas, list_eps):

print("List of OTAs Available:")

print("=======================")

or i in list_otas:

print(i)

print("List of EPs Available:")

print("=======================")

for i in list_eps:

print(i)

def task_2(list_otas, list_eps, tuples):

print("Displaying selected combinations:")

print("=================================")

print("")

for i, j in tuples:

print("***SYSTEM***")

print("============")

ota = list_otas[i]

ep = list_eps[j]

print(ota)

print(ep)

print(f"Eff Mag : {OpticalToolbox.effective_magnification(ota, ep)}")

print(f"F-ratio : f / {OpticalToolbox.f_ratio(ota)}")

print(f"True FOV: {OpticalToolbox.true_fov(ota, ep)} deg")

print("")

def task_3(list_otas, list_eps):

print("Problematic Eyepiece Focal Lengths:")

print("===================================")

lst = []

for x in list_otas:

for y in list_eps:

if not OpticalToolbox.eyepiece_usability(x, y):

z = y.get_focal_length()

if z not in lst:

lst.append(z)

lst.sort()

print(f"Focal Length List (mm): {lst}")

def read_data():

file_otas = open("otas.txt", "r")

file_eps = open("eps.txt", "r")

file_mounts = open("mounts.txt", "r")

list_otas = []

list_eps = []

list_mounts = []

for line in file_otas.readlines():

if line[0] == '#':

continue

params = line.strip('\r\n').split(',')

list_otas.append(OTA(params[0], int(params[1]), int(params[2]), params[3], int(params[4])))

for line in file_eps.readlines():

if line[0] == '#':

continue

params = line.strip('\r\n').split(',')

list_eps.append(EP(params[0], int(params[1]), int(params[2])))

; for line in file_mounts.readlines():

if line[0] == '#':

continue

params = line.strip('\r\n').split(',')

list_mounts.append(Mount(params[0], params[1], params[2], int(params[3]), params[4]))

file_otas.close()

file_eps.close()

file_mounts.close()

return list_eps, list_otas, list_mounts

def task_4(list_eps, list_otas, list_mounts, tuples):

# This function will receive the list if OTAs, EPs, Mounts and the tuples with the index

# This function will print the list of packages

packages = []

package_id = 1

for tup in tuples:

ota_idx = tup[0]

mount_idx = tup[1]

eps_tup = tup[2] # this is a tuple also

ota = list_otas[ota_idx]

mount = list_mounts[mount_idx]

package_id += 1

package = Package(package_id, ota, mount)

for ep_idx in eps_tup:

ep = list_eps[ep_idx]

package.add_EP(ep)

# print Package

packages.append(package)

print(package)

def main():

list_eps, list_otas, list_mounts = read_data()

# Task 1: Print out the two lists

task_1(list_otas, list_eps)

# Task 2: Use the given set of tuples which specify OTA and EP combinations, by index within each file.

tuples = [(0, 2), (2, 18), (2, 19), (0, 5), (3, 0), (7, 18), (3, 16), (0, 12)]

task_2(list_otas, list_eps, tuples)

# Task 3: Check all OTA/EP combinations that are UNUSABLE.

task_3(list_otas, list_eps)

# Define the tuples

tuples = [

(8, 4, (17, 6)),

(9, 4, (19, 4, 7)),

(3, 2, (0, 16)),

(4, 11, (12, 4, 15)),

(1, 3, (16, 7)),

(7, 8, (5,)),

(14, 7, (11, 12, 7)),

(14, 10, (17,)),

(8, 8, (17, 5, 6)),

(5, 11, (2, 4)),

(12, 4, (0, 19, 13)),

(11, 1, (10, 5)),

(2, 16, (12, 5, 15)),

(9, 6, (12, 6)),

(11, 5, (5,)),

(14, 1, (9, 18, 19)),

(15, 8, (10, 13)),

(7, 15, (4, 14)),

(1, 17, (15,)),

(8, 7, (18, 19, 5)),

(3, 9, (12, 14)),

(13, 7, (9, 4)),

(13, 14, (5,)),

(3, 0, (19, 15)),

(7, 2, (0, 8)),

(10, 19, (5,)),

(13, 2, (8, 10, 6)),

(3, 11, (19, 11, 4)),

(15, 19, (8, 15)),

(8, 13, (2, 15)),

(0, 13, (19, 4, 7)),

(7, 8, (18, 3, 14))]

task_4(list_eps, list_otas, list_mounts, tuples)

if __name__ == '__main__':

main()

MOUNT

class Mount:

_physical_type: str

_motion_type: str

_mount_plate_type: str

_weight_rating: int

_computarized_goto: bool

_type_names = {'T': "Tripod", 'D': "Dobsonian base"}

_motion_types = {'AA': "Altitude-Azimuth", 'EQ': "Equatorial"}

_mount_plate_types = {'NA': "Not Applicable", 'V': 'Vixen 1.75"', 'D': 'Losmandy 3"'}

def __init__(self, physical_type: str, motion_type: str, mount_plate_type: str, weight_rating: int, computerized_goto: str):

self._physical_type = physical_type

self._motion_type = motion_type

self._mount_plate_type = mount_plate_type

self._weight_rating = weight_rating

if computerized_goto == 'Y':

self._computarized_goto = True

else:

self._computarized_goto = False

def get_physical_type(self) -> str:

return self._type_names[self._physical_type]

def get_motion_type(self) -> str:

return self._motion_types[self._motion_type]

def get_mount_plate_type(self) -> str:

return self._mount_plate_types[self._mount_plate_type]

def get_weight_rating(self) -> float:

return self._weight_rating

def get_computarized_goto(self) -> bool:

return self._computarized_goto

def get_computarized_goto_str(self) -> str:

goto = "No"

if self._computarized_goto:

goto = "Yes"

return goto

def __str__(self):

ret = "Mount:\n"

ret += " Physical Type: " + self.get_physical_type() + "\n"

ret += " Motion Type: " + self.get_motion_type() + "\n"

ret += " Mount Plate Type: " + self.get_mount_plate_type() + "\n"

ret += " Mount Weight Rating: " + str(self.get_weight_rating()) + "kg maximum\n"

ret += " Mount is GOTO: " + self.get_computarized_goto_str()

return ret