Using python create function that:
The stars.txt dataset1 consists of temperatures and magnitudes for 7860 nearby stars. The magnitude of stars corresponds to a star’s brightness. A star’s temperature is estimated by the color of light the star emits. Write functions that read the stars.txt file and: • find the hottest star • find the coldest star • find the brightest star • find the darkest star Function name: find_hottest_star() Parameters/arguments: filename Returns: temperature Function name: find_coldest_star() Parameters/arguments: filename Returns: temperature Function name: find_brightest_star() Parameters/arguments: filename Returns: magnitude Function name: find_darkest_star() Parameters/arguments: filename Returns: magnitude
The stars.txt dataset1 consists of temperatures and magnitudes for 7860 nearby stars
(available at http://www-personal.umich.edu/~mejn/computational-physics/stars.txt)
1) Function to find the hottest star:
import numpy as np
def find_hottest_star():
x = np.loadtxt("Desktop/star_folder/stars.txt")
T1,T2= np.genfromtxt("Desktop/star_folder/stars.txt", unpack=True) //binding variables to the columns in the text file
T1max = max(T1) //T1 is temperature & T2 is magnitude
print(T1max) //hottest star will have maximum temperature,hence max(T1)
find_hottest_star()
Output: 14786.0720701

2)Function to find the coolest star:
import numpy as np
def find_coolest_star():
x = np.loadtxt("Desktop/star_folder/stars.txt")
T1,T2= np.genfromtxt("Desktop/star_folder/stars.txt",
unpack=True)
T1min = min(T1) //coolest star will have minimum
temperature,hence min(T1)
print(T1min)
find_coolest_star()
Output: 683.14508541

3)Function to find the brightest star:
import numpy as np
def find_brightest_star():
x = np.loadtxt("Desktop/star_folder/stars.txt")
T1,T2= np.genfromtxt("Desktop/star_folder/stars.txt",
unpack=True)
T2max = max(T2) //brightest star will have maximum magnitude,hence
max(T2)
print(T2max)
find_brightest_star()
Output: 18.08

4)Function to find the darkest star:
import numpy as np
def find_darkest_star():
x = np.loadtxt("Desktop/star_folder/stars.txt")
T1,T2= np.genfromtxt("Desktop/star_folder/stars.txt",
unpack=True)
T2min = min(T2) //darkest star will have minimum
magnitude,hence min(T2)
print(T2min)
find_darkest_star()
Output: -2.77

Using python create function that: The stars.txt dataset1 consists of temperatures and magnitudes for 7860 nearby...
"PYTHON" 1. a. Create a file (module) named camera_picture.py. b. Write a function, take_picture_effect, that takes two parameters, the filename and an effect. c. Take a picture with the filename and effect. Use camera.effect to set the effect. Use help(PiCamera) to find the effects which you can apply. d. Create a second file use_camera.py. e. Import the take_picture_effect function from the camera_picture module. f. Prompt the user for the filename. g. Prompt the user for the image_effect. help(PiCamera) to see...
In Python,1.6. Recommend a Movie Create a function that counts how many keywords are similar in a set of movie reviews and recommend the movie with the most similar number of keywords. The solution to this task will require the use of dictionaries. The film reviews & keywords are in a file called film_reviews.txt, separated by commas. The first term is the movie name, the remaining terms are the film’s keyword tags (i.e., “amazing", “poetic", “scary", etc.). Function name: similar_movie()...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file...
Can someone do this first function? Using python and API!
API
KEY: 8bb45882c0894d8c1ad25a8dcc157c09
Function name: get_movie_recommendations Parameters: movie_ids (list of ints) Returns: recommended movie titles (list of strings) Description: Write a function that takes in a list of movie IDs. Find the movies corresponding to the IDs. If the popularity of the movie is greater than 20, add the movie title (string) to a list. Return the list of titles. Note: Your function should be able to handle invalid movie ids....
PYTHON 3.6 Overview In this assignment we implement a class called TripleString. It consists of a few instance attribute and a few instance methods to support those attributes. In the next assignment, the TripleString class will help us create a more involved application. Before we do that though, we have to thoroughly test our TripleString implementation. Specifications The class TripleString will contain symbolic constants, instance attributes, and instance methods. ▶ Class symbolic constants This class has 3 symbolic constants, which...