hw02
.py
keyboard_arrow_up
School
University of Michigan *
*We aren’t endorsed by this school
Course
206
Subject
Computer Science
Date
Feb 20, 2024
Type
py
Pages
6
Uploaded by erzas088
# -*- coding: utf-8 -*-
"""hw02.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1MolVV1OaiWD8Xb-gJA-i8LspM1aAODWC
"""
import numpy as np # run this first
"""# Homework 2, Stats 206/DataSci 101
## Question 1
We will start this homework with some questions on collections in Python.
### Q1.a
Recall that *sets* are collections where each value in the collection only appears once.
Using the `set` function, turn both of these strings into sets. Then use set methods to find
* How many letters are shared between the two names?
* Which letters are in "George Washington" that are not in "Abraham Lincoln"?
* How many letters are in neither president's name?
"""
gw = "George Washington".lower()
al = "Abraham Lincoln".lower()
az = "abcdefghijklmnopqrstuvwxyz"
gw_set = set(gw)
al_set = set(al)
az_set = set(az)
print(gw_set & al_set)
print(gw_set - al_set)
print(az_set - (gw_set & al_set))
"""
### Q1.b
Use a `for` loop to find the unique values in the lunch orders below. Using Python,
print out the number of unique items being ordered. (*Hint*: You can use `set()` to
create an empty set.)"""
lunch_orders = [{"pasta", "coffee"},
{"fries","sandwich", "cookie"},
{"pasta", "salad", "water"},
{"salad", "pasta", "coffee"},
{"sandwich", "water"}]
u_set = set()
for order in lunch_orders:
for item in order:
u_set.add(item)
print(u_set)
"""### Q1.c
Here is a menu at the resturant, with items and their cost:
| Item | Price | Vegetarian |
| --- | --- | --- |
| salad | 8 | True |
| soup | 5 | False |
| pasta | 12 | True |
| sandwich | 9 | False |
| burger | 13 | False |
| fries | 6 | True |
| cake | 6 | True |
| cookie| 3 | True |
| water | 0 | True |
| coffee| 2 | True |
| soda | 3 | True |
Create a dictionary called `menu` that has the item names as keys and a two-tuple with (price, vegetarian) as the value.
Demonstrate by retrieving the price and vegetarian status of "burger".
"""
menu = {"salad" : (8, True),
"soup" : (5, False),
"pasta" : (12, True),
"sandwich": (9, False),
"burger": (13, False),
"fries": (6, True),
"cake": (6, True),
"cookie": (3, True),
"water": (0, True),
"coffee": (2, True),
"soda": (3, True)
}
print(menu["burger"])
"""### Q1.d
Write a function that takes a lunch order (a set of menu items) and returns the total price.
Write a function that takes a lunch order a returns true if the entire order is vegetarian.
Use list comprehensions to compute the price of each order and whether each order
is vegtarian.
"""
def total_price(lunch_order):
price = 0
for item in lunch_order:
price += menu[item][0]
return price
def veg_status(lunch_order):
return all(menu[item][1] for item in order)
# Hints: try running the following code
# ("this", "is", "a tuple")[1]
# [s.upper() for s in {"hello", "world"}]
"""### Q1.e
When you have completed your menu in the part (c) you can remove the `#` charcters make this code run:
"""
menu_dict = {
"name": list(menu.keys()),
"price": [i[0] for i in menu.values()],
"vegetarian": [i[1] for i in menu.values()]
}
"""Use this table to compute the following:
* What is the price of the most expensive item in the list?
* What is the name of the most expensive item? (You can use the `np.argmax()` function to help you.)
* How many vegetarian items are there?
"""
import numpy as np
#price of most expensive
highest = max(menu_dict["price"])
print(highest)
#name of most expensive
highest_index = np.argmax(menu_dict["price"])
item_name = menu_dict["name"][highest_index]
print(item_name)
#number of veg items
num_veg_items = sum(menu_dict["vegetarian"])
print(num_veg_items)
"""### Question 2
"""
# run this to do question 2
import pandas as pd
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
PYTHON / DATABRICKS
Please experiment with the ALS algorithm, you can use the following notebook as starting template: https://databricks-prod-cloudfront.cloud.databricks.com/public/4027ec902e239c93eaaa8714f173bcfc/42740061589303/2161112564136160/8105921225255291/latest.html
1. Try to train and run the model on the 20 Million movie ratings dataset instead of the 1 Million one. Files:
/databricks-datasets/cs110x/ml-20m/data-001/movies.csv
/databricks-datasets/cs110x/ml-20m/data-001/ratings.csv
2. Test with various values of: ranks, regularization parameter, number of iterations.
Compare the models and find the best model based on the error value (i.e RMSE).
The documenation of the algorithm can be found at: https://spark.apache.org/docs/3.3.1/ml-collaborative-filtering.html
https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.ml.recommendation.ALS.html#pyspark.ml.recommendation.ALS
Prepare a table with at least 10 of your own ratings for the movies that you select and…
arrow_forward
Description
i
What is timestamp?
Note that we have only timestamps, which ALWAYS contain yyyy-mm-dd as a date, hh:mm:ss as a
time, and +/-zzzz as a timezone.
time
2017-10-14 00:11:20 +0000
date
time zone
12345
+
timeconverter.py
1 def convert_time(timestamp):
#NOTE: COMPLETE THE CODE FROM HERE!
6 #DO NOT MODIFY THE CONTENT HERE:
7 def print_result(hour, minute):
8
9
print("The time is {}:{}".format(hour, minute))
10 #DO NOT MODIFY THE CONTENT HERE:
11 timestamp_list = ['2017-10-14 00:11:20 +0000',
12 '2022-03-24 07:22:16 -0400'
Topic: Timestamp Converter
Write a program timeconverter.py that has two functions: 1) The function convert_time :
for extracting the hour and minute from a timestamp and 2) The function print_result: for
printing the results.
Note that the two functions should be called under the loop.
1) The function convert_time should:
1. take the timestamp from the function call,
2. separate time from date and time zone,
3. split it into hour, minute and seconds,
4. extract…
arrow_forward
_555523.21 LAB: The __str__() method (Use Python).
arrow_forward
File read write and string manipulation
data1.txt(down below)
4,5-t 2,4-d 20-p7int 2D 2nd 2 1080 &c 10-p7int 10th 11-p7int 12-p7int 16-p7int 18-p7int 1st 2,4,5-t 2,4-d 20-p7int 2D 2nd 30-30 3D 3-D 3M 3rd 48-p7int 4-D 4GL 4H 4th 5-p7int 5-T 5th 6-p7int 6th 7-p7int 7th 8-p7int 8th 9-p7int 9th @ @' @- @&M @&P @. @.@.@. @.B. @.B.@. @.C. @.D. @.D.C. @.F. @.F.@.M. @.G. @.H. @.I. @.I.@. @.I.D. @.L. @.L.P. @.M. @.M.@. @.M.D.G. @.N. @.p. @.r. @.R.C.S. @.U. @.U.C. @.V. @.w. @.W.O.L. @/C @/F j54rs54y54d J54rs54yit54 j54rs54yit54s J54rs54ym@n j54rs54ys j54rs54y's J54rs54yvill54 j54rt J54rubb@@l J54rubb@l J54rus@l54m J54rus@l54mit54 j54rvi@ j54rvin j54rvin@ j54rvin54 J54rvis J54rk J54S J54sh J54sh54r J54smin54 j54sp54r J54sp54rs54n J54ss J54ss@ J54ss@b54ll j54ss@k5454d J54ss@lin J54ss@lyn j54ss@my j54ss@mi54s J54ss@myn J54ss@min54 j54ss@nt J54ss54 J54ss54@n j54ss54d J54ss5454 J54ss54y J54ss54lyn J54ss54lt7n J54ss54n j54ss54s J54ssi J54ssy J54ssic@ J54ssi54 kikkl54 kikkl54d kikkl54s…
arrow_forward
JavaScript Loops
Create an HTML
document called
assignment2.html
that implements a webpage that
dynamically creates (using JavaScript code) a 15X15 HTML table and displays in each
cell the (row, column) information for that cell. Allow the user to select the number of
rows and columns to redraw a new table.
Follow these guidelines to implement your assignment:
1.
Create a JavaScript file called assignment2.js and write the code for a function
that draws the table.
2.
Invoke the function when the visitor clicks on the assignment2.html page.
3.
Load the assignment2.js file at the end of the body in assignment2.html.
4.
(
10% of the grade
) Accept user input for the number of rows and columns in the
table.
5.
(
10% of the grade
) Use good web design practices to enhance visually your
html page. Add a title, picture, colors, copyright line, etc.
arrow_forward
Create a new file cart.html
You must get and set the data on the web page by using document.getElementById( ). Each HTML element on the web page already has an id so it is easy.
No need for a loop to go through the list of products, there is only 2 products and the info is hard coded on the web page.
You must write the code for function cartTotal().
arrow_forward
Octave assignment 1-Introduction to Octave
Introduction
This assignment is meant to be a gentle introduction to Octave, the free version of Matlab. It
assumes that you have no prior coding experience.
Objectives
Download Octave and run it or use https://octave-online.net/
Learn the basics of the Octave GUI.
• Learn how to create a short executable file called an m-file (.m extension) and run it.
• Learn what a data type is.
• Learn how to declare variables of different data types.
• Learn how to create matrices.
• Learn how to use several of Octave’s functions for creating objects with random
numbers.
Instructions
1.) Create a file call it with the form exercise_1_first name_last name. Include the
underscores in your file name. At the top of the file add the comment "“My first Octave
assignment. I'm so excited, I just can't hide it."
2.) Create the following variables
a = 2.3;
b = -87.3;
A = [1,2; 4,5];
Create a matrix 2 × 2 B using the rand() function.
Create two random complex…
arrow_forward
save_compressed_image: takes a nested list and a filename (string) as input, and saves it in the
compressed PGM format to a file with the given filename. If the image matrix given as input is not
a valid compressed PGM image matrix, instead raise a AssertionError with an appropriate error
message.
>>> save_compressed_image([["0x5", "200x2"], ["111x7"]], "test.pgm.compressed")
>>> fobj open("test.pgm.compressed", 'r')
>>> fobj.read()
=
'P2C\\n7_2\\n255\\n0x5 200x2\\n111x7\\n'
>>> fobj.close()
>>> image
[["0x5", "200x2"], ["111x7"]]
>>> save_compressed_image(image, "test.pgm")
>>> image2 =
>>> image
True
=
==
load_compressed_image("test.pgm")
image2
• save_image: takes a nested list and a filename (string) as input. Checks the type of elements in the
list If thou are intogors thon saves the posted list as a PCM imago matrix into a file with the given
arrow_forward
Please written by computer source
I want to add an if statment to my code for overtime if the number of hours are over 40 but im stuck on how to do it,
This is a link for my code: https://prnt.sc/1a-IVCvrRU_m
This is what I am trying to add to my code : https://prnt.sc/8g5_4YbMXF0b
arrow_forward
You can download;
restadata.txt : https://dosyam.org/2D1j/restdata.txt
restaurant.c :https://dosyam.org/2D1i/restaurant.c
Given code should be modify in C Language. Can someone help me please ?
#include <stdio.h> // Do not edit these directives or add another.#include <stdlib.h>#include <string.h>#include <time.h>
#define MAX 1000 // Do not edit this macro.
typedef struct // Do not edit this struct.{unsigned long restaurant_id;char restaurant_name[15];char description[127];double rate;char cuisine[31];unsigned short opening_year;unsigned long capacity;char city[31];char address[63];char owner[31];} RECORD_t, *RECORD;
/* DECLARE YOUR FUNCTION PROTOTYPES HERE. */void find_by_opening_year(unsigned short opening_year, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end, unsigned long *p_found_num, RECORD **p_found_restaurants);RECORD find_by_restaurant_name(char *restaurant_name, RECORD *restaurant_array, unsigned long size,…
arrow_forward
QUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION.
AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , salary.cpp )
----------------- TEMPLATES BELOW FOR SOLUTION -----------------------
salary.cpp
#include<iostream>using namespace std;class Salary{public:string name;float HRA,DA,basic;public:Salary(){}Salary(string name,float basic, float hra,float da){name=name;basic=basic;HRA=hra;DA=da; }public:void calculateSalary(int taxType){//Fill your code here}};
main.cpp
#include<iostream>#include "Salary.cpp"using namespace std;
int main(){string name;float Basic,HRA,DA;int choice;cout<<"Enter the Name of the employee :"<<endl;cin>>name;cout<<"Enter the Basic pay :"<<endl;cin>>Basic;cout<<"Enter the HRA percentage :"<<endl;cin>>HRA;cout<<"Enter the DA percentage :"<<endl;cin>>DA;cout<<"Enter if the tax is fixed or variable…
arrow_forward
8Her.e
Provide the correct c++ code for below code /****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include using namespace std; #include int hextodec(char num[]) { int len = strlen(num); int base = 1; int temp = 0; for (int i=len-1; i>=0; i--) { if (num[i]>='0' && num[i]='A' && num[i]..
arrow_forward
PYTHON
import pandas as pdfrom datetime import dateimport sys
from sklearn.preprocessing import OrdinalEncoder
def series_report( series, is_ordinal=False, is_continuous=False, is_categorical=False): print(f"{series.name}: {series.dtype}") ###### Your code here ###### # Check command line argumentsif len(sys.argv) < 2: print(f"Usage: python3 {sys.argv[0]} <input_file>") exit(1)
# Read in the datadf = pd.read_csv( sys.argv[1], index_col="employee_id")
# Convert strings to dates for dob and deathdf['dob'] = df['dob'].apply(lambda x: date.fromisoformat(x))df['death'] = df['death'].apply(lambda x: date.fromisoformat(x))
# Show the shape of the dataframe(row_count, col_count) = df.shapeprint(f"*** Basics ***")print(f"Rows: {row_count:,}")print(f"Columns: {col_count}")
# Do a report for each columnprint(f"\n*** Columns ***")series_report(df.index, is_ordinal=True)series_report(df["gender"], is_categorical=True)series_report(df["height"], is_ordinal=True,…
arrow_forward
yperion Dev
Create a python file called IrisDataset Plot.py.
Write code to produce the following figure and save your figure.
VİKİMİNİNİ Hiddink ddrink ddddinst
onanonon Thongnanonohanananano
inangranaro
4.5.6.5.6.7.7.3.8.5
52.025
Mandintot
6 7
04.5. 6.7.7.3.8.5. J.A.5.6.5.6.7.07.3.88,5
4.04.55,0 52.02.53.03.54.04.55.0 52.02.53.03.54.04.55,0
Copyright © 2021 Hyperion Dev. All rights reserved.
ji
5 6 7
0.5
0.0
-0.5.00.51.01.52.02.53.0-0.5.00.51.01.52.02.53.0-0.50.00.51.01.52.02.53.0
Hint: Note that there are 2 features being used for each subplot. i.e. The
first 2 subplots came from our example of plotting the iris dataset. This is
a permutation problem. From 4 features choose 2 which equals 12
choices in total. That is why there are 12 subplots in total.
arrow_forward
Hello, C++ programming
The source code starter file is included as an attachment
The file starts with this string as the input to your encryption algorithmLLSNEEIRUIGNUL-CHXUADUPUGD-RTYI61IE-GDD5E0-607325-8576A598DFJ-EH8IKD7E037FJKE87--54625B6870-FJE941597---FHE7FHJ8KEN436-471369073C8767DFE-7KO8FLKE6895-8934When properly decoded, the answer will describe how might you feel after you get this encyption scheme working
Here is a list of steps needed to unencrypt your passcode, which is also found in the source code file:
Create an empty stack
The first 15 characters of the string get pushed into the stack in order (LLSNEEIRUIGNUL-)
Create an empty queue
The next 16 characters of the string get pushed into the queue in order (CHXUADUPUGD-RTYI)
Create an empty deque
For the remaining characters of the string in order (61IE-GDD5E0-607325-8576A598DFJ...) do the following conditionally:
1 = Pop the stack
2 = Pop the queue
3 = Pop the front of the deque
4 = Pop the back of the deque
5 = Move…
arrow_forward
Create a simple web application that converts decimal into binary, octal, hexadecimal using functions and arrays.
Reminder: Do not use built in functions for the conversion.
Attach the php file and screenshots of your codes and output.
arrow_forward
RStudio
How to filter these data so that 1 and 2 are the headers in RStudio?
BORN EDUC1 161 141 161 122 122 101 131 121 111 121 142 121 121 132 12
arrow_forward
https://docs.google.com/document/d/1WAkeWOTbOEMM-EvVa7IJTJFnwmEMz1_rQihnFkARapc/edit?usp=sharing
hw help
here is the files for the program
only will be editing extendedavlnode.java and extendedavltree.java
arrow_forward
JAVA
This should be easy
I have this data.txt:
4 40 80
52 41 72 61
71 60 50 52 61
77 41 61 70 79 41
67 60 50 61 76
and this code:
// THIS IS THE ONE YOU ARE LOOKING FORE
import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;
//https://www.chegg.com/homework-help/questions-and-answers/program-1-histogram-takes-integer-n-two-integers-left-right-uses-stddraw-plot-histogram-co-q30777519?trackid=e3045eb02494&strackid=cc33c4210bce&ii=1// D:/documents/TESU/000_courses/COS-111 Intro to Programming (-OL009)/eclipse-workspace/COS_111/src/data.txt
public class zzz{
public static void main(String[] args) throws FileNotFoundException{ File file = new File("D:\\documents\\TESU\\000_courses\\COS-111 Intro to Programming (-OL009)\\eclipse-workspace\\COS_111\\src\\data.txt");Scanner scanner = new Scanner(file);// get the first 3 conditions// n = categoriseint n = scanner.nextInt();int left = scanner.nextInt();int right = scanner.nextInt();// find catigories//…
arrow_forward
WebConnect 3270
Sphinx of Hatsheps...
- Question Completion Status:
Based on this information, complete the code for numbered region 3.
QUESTION 10
("Enter a number:"))
Fill each of the numbered areas so that the code you create asks the user to enter a whole number using the keyboard and
store that number into variable x.
QUESTION 11
if(x<0 or x10):
print("Invalid number! ")
The piece of code above checks whether x is between 0 and 10, If not it prints a text.
Click
arrow_forward
Q4. The attached Java program (Recursion_Demo.java) (C# version is also
attached) demonstrates the concept of recursion. The program inputs the value
of n from the user and then the recursive RDemo method prints the following
sequence:
n (n-1) (n-2)... 1123... n
Execute the program and check it out for yourself. You will write a MIPS
program which MUST use a non-leaf procedure to implement this recursive
method. Your program will define a non-leaf procedure RDemo which will be
called recursively for n>=1. RDemo will return when n<1. Your program will
print the user prompt and take n as an input in the main program. The output
on the screen must be just similar to the Java program - there will be space
between the integers. Obviously, your MIPS program will not implement the
concept of class.
(See next page)
arrow_forward
You can download;
restadata.txt : https://dosyam.org/2D1j/restdata.txt
restaurant.c :https://dosyam.org/2D1i/restaurant.c
Given code should be modified in C Language.
#include <stdio.h> // Do not edit these directives or add another.#include <stdlib.h>#include <string.h>#include <time.h>
#define MAX 1000 // Do not edit this macro.
typedef struct // Do not edit this struct.{unsigned long restaurant_id;char restaurant_name[15];char description[127];double rate;char cuisine[31];unsigned short opening_year;unsigned long capacity;char city[31];char address[63];char owner[31];} RECORD_t, *RECORD;
/* DECLARE YOUR FUNCTION PROTOTYPES HERE. */void find_by_opening_year(unsigned short opening_year, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end, unsigned long *p_found_num, RECORD **p_found_restaurants);RECORD find_by_restaurant_name(char *restaurant_name, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long…
arrow_forward
Python - Why does this code not execute properly?
Code:
import csv import matplotlib.pyplot as plt def read_csv(iso_code): with open('owid-covid-data.csv', encoding='utf-8-sig', mode='r') as csvFormat: csvFile = csv.reader(csvFormat) day = [] cases = [] line = 1 for row in csvFile: line += 1 if row[0] == iso_code: if line > 1: day.append(int(row[3])) cases.append(int(row[4])) return day, cases def data_charts(data1, data2, type): fig = plt.figure() ax = fig.add_subplot(1, 1, 1) if type == 'bar': ax.bar(data1, data2) elif type == 'line': ax.plot(data1, data2) elif type == 'scatter': ax.scatter(data1, data2, s=2, c='blue', marker='+') ax.set_xlabel('Day') ax.set_ylabel('New Cases') ax.set_title('New cases by day for', type) ax.grid() plt.show() iso_code = input('Enter a country ISO code like KOR, MEX, USA, CAN, NZL: ') plotData = input('Enter chart type line, bar, or scatter: ') x, y = read_csv(iso_code) data_charts(x, y, plotData)
Example File:…
arrow_forward
In PHP, $_SESSION is a predefined array that is used to:
1- Store the request data coming from web browser automatically.
2- Store data that can be used in the other pages until the user logs out from the website.
3- Store data temporarily until the fulfilment of the request.
4- Store data permanently in the Web Server.
arrow_forward
In Python,
utilize the file pylang.txt
(information included in the file py.lang.txt below)
pylang.txt
—————
Python language is incredibly easy to use and learn
for new beginners and newcomers. The python language
is one of the most accessible programming languages
available because it has simplified syntax and not
complicated, which gives more emphasis on natural
language. Due to its ease of learning and usage,
python codes can be easily written and executed much
faster than other programming languages.
——————————————-
Create a program that replaces every occurrence of a string from the file above with a user-selected word. The program should prompt user to enter the filename, a string to be substituted and a string to substitute it with. The program will open a file to read, then close the file. Replace one string with another, then open the file to write out the new string, then close it. Then finally, open the file to read again so the new context can be printed.…
arrow_forward
Exclude any existing source code files that may already be in your IDE project and add a new onenamed C2A1E5_ResizeAlloc.c. Also add instructor-supplied source code file C2A1E5_main-Driver.c. Donot write a main function! main already exists in the instructor-supplied file and it will use the code youwrite.
File C2A1E5_ResizeAlloc.c (I used 8 lines of code but you don’t have to match or beat that.)must contain the definition of a function named ResizeAlloc that returns type “pointer to void”and has three parameters. The first is named pOld and is of type “pointer to void” while the secondand third are named newSize and oldSize, respectively, and are both of type size_t.ResizeAlloc either dynamically allocates an entirely new block of memory containing newSizebytes or, in effect, resizes an existing block in pOld containing oldSize bytes to contain newSizebytes. When resizing occurs all existing data that will fit into newSize bytes will be preserved.ResizeAlloc may not call calloc or…
arrow_forward
A testnavclient.psonsvc.net/#/question/2896870d-7203-41a3-a0c3-e2d6bace85a5/34c0be18-53a8-4234-b085-4759c8.
Review -
A Bookmark
Quiz 6P1.3 Sound Waves (COPY) / 8 of 13
Which choice best identifies media through which sound can travel?
A. vacuums and liquids
B. solids and outer space
C. gases and outer space
D. solids and liquids
X
arrow_forward
Please help with the 1 Python question
Data File: https://docs.google.com/spreadsheets/d/1-S_xnAQXa1QCoWQt7xyvxo42XRNC1QBd/edit?usp=sharing&ouid=112107649557425878726&rtpof=true&sd=true
%%capture############################################################## EXECUTE THIS CELL BEFORE YOU TO TEST YOUR SOLUTIONS ##############################################################import imp, os, syssol = imp.load_compiled("solutions", "./solutions.py")sol.get_solutions("imdb.xlsx")from nose.tools import assert_equalfrom pandas.util.testing import assert_frame_equal, assert_series_equal
# Loading the dataimport pandas as pdimport numpy as np
xls = pd.ExcelFile('imdb.xlsx')df = xls.parse('imdb')df_directors = xls.parse('directors')df_countries = xls.parse('countries')
df = pd.merge(left=df, right=df_countries, how='inner', left_on='country_id', right_on='id')
df = pd.merge(left=df, right=df_directors, how='inner', left_on='director_id',…
arrow_forward
- ONE source files: yourName_LAB2 py
- One image files: jpg. yourName LAB2 output.jpg.
NOTE: Separate the parts of the lab by outputting the question # and printing a line.
earch
Directions
1. Variables and literals
• Read all the directions before you start coding!
• You will create a program, in your IDE, that uses a variable.
- Define a variable, something like vari
- Then assign the number 5 to your variable. If you need help with this refer to the Variable paee here in Canvas This should be the first line of your program and it should look something like this. Use the numeric value of 5 instead of O
x=0
• Next write code to print the following statement on your screen My favorite number is 5
- You should use the print function (printt "blah blah blah") to do this.
• Do not code the 5 as a literal (51, it should be a number (so no quotes around it).
• You should use your variable. in a print statement, to print the value, such as:
printt"My favorite number is number)
• Where number…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- PYTHON / DATABRICKS Please experiment with the ALS algorithm, you can use the following notebook as starting template: https://databricks-prod-cloudfront.cloud.databricks.com/public/4027ec902e239c93eaaa8714f173bcfc/42740061589303/2161112564136160/8105921225255291/latest.html 1. Try to train and run the model on the 20 Million movie ratings dataset instead of the 1 Million one. Files: /databricks-datasets/cs110x/ml-20m/data-001/movies.csv /databricks-datasets/cs110x/ml-20m/data-001/ratings.csv 2. Test with various values of: ranks, regularization parameter, number of iterations. Compare the models and find the best model based on the error value (i.e RMSE). The documenation of the algorithm can be found at: https://spark.apache.org/docs/3.3.1/ml-collaborative-filtering.html https://spark.apache.org/docs/latest/api/python/reference/api/pyspark.ml.recommendation.ALS.html#pyspark.ml.recommendation.ALS Prepare a table with at least 10 of your own ratings for the movies that you select and…arrow_forwardDescription i What is timestamp? Note that we have only timestamps, which ALWAYS contain yyyy-mm-dd as a date, hh:mm:ss as a time, and +/-zzzz as a timezone. time 2017-10-14 00:11:20 +0000 date time zone 12345 + timeconverter.py 1 def convert_time(timestamp): #NOTE: COMPLETE THE CODE FROM HERE! 6 #DO NOT MODIFY THE CONTENT HERE: 7 def print_result(hour, minute): 8 9 print("The time is {}:{}".format(hour, minute)) 10 #DO NOT MODIFY THE CONTENT HERE: 11 timestamp_list = ['2017-10-14 00:11:20 +0000', 12 '2022-03-24 07:22:16 -0400' Topic: Timestamp Converter Write a program timeconverter.py that has two functions: 1) The function convert_time : for extracting the hour and minute from a timestamp and 2) The function print_result: for printing the results. Note that the two functions should be called under the loop. 1) The function convert_time should: 1. take the timestamp from the function call, 2. separate time from date and time zone, 3. split it into hour, minute and seconds, 4. extract…arrow_forward_555523.21 LAB: The __str__() method (Use Python).arrow_forward
- File read write and string manipulation data1.txt(down below) 4,5-t 2,4-d 20-p7int 2D 2nd 2 1080 &c 10-p7int 10th 11-p7int 12-p7int 16-p7int 18-p7int 1st 2,4,5-t 2,4-d 20-p7int 2D 2nd 30-30 3D 3-D 3M 3rd 48-p7int 4-D 4GL 4H 4th 5-p7int 5-T 5th 6-p7int 6th 7-p7int 7th 8-p7int 8th 9-p7int 9th @ @' @- @&M @&P @. @.@.@. @.B. @.B.@. @.C. @.D. @.D.C. @.F. @.F.@.M. @.G. @.H. @.I. @.I.@. @.I.D. @.L. @.L.P. @.M. @.M.@. @.M.D.G. @.N. @.p. @.r. @.R.C.S. @.U. @.U.C. @.V. @.w. @.W.O.L. @/C @/F j54rs54y54d J54rs54yit54 j54rs54yit54s J54rs54ym@n j54rs54ys j54rs54y's J54rs54yvill54 j54rt J54rubb@@l J54rubb@l J54rus@l54m J54rus@l54mit54 j54rvi@ j54rvin j54rvin@ j54rvin54 J54rvis J54rk J54S J54sh J54sh54r J54smin54 j54sp54r J54sp54rs54n J54ss J54ss@ J54ss@b54ll j54ss@k5454d J54ss@lin J54ss@lyn j54ss@my j54ss@mi54s J54ss@myn J54ss@min54 j54ss@nt J54ss54 J54ss54@n j54ss54d J54ss5454 J54ss54y J54ss54lyn J54ss54lt7n J54ss54n j54ss54s J54ssi J54ssy J54ssic@ J54ssi54 kikkl54 kikkl54d kikkl54s…arrow_forwardJavaScript Loops Create an HTML document called assignment2.html that implements a webpage that dynamically creates (using JavaScript code) a 15X15 HTML table and displays in each cell the (row, column) information for that cell. Allow the user to select the number of rows and columns to redraw a new table. Follow these guidelines to implement your assignment: 1. Create a JavaScript file called assignment2.js and write the code for a function that draws the table. 2. Invoke the function when the visitor clicks on the assignment2.html page. 3. Load the assignment2.js file at the end of the body in assignment2.html. 4. ( 10% of the grade ) Accept user input for the number of rows and columns in the table. 5. ( 10% of the grade ) Use good web design practices to enhance visually your html page. Add a title, picture, colors, copyright line, etc.arrow_forwardCreate a new file cart.html You must get and set the data on the web page by using document.getElementById( ). Each HTML element on the web page already has an id so it is easy. No need for a loop to go through the list of products, there is only 2 products and the info is hard coded on the web page. You must write the code for function cartTotal().arrow_forward
- Octave assignment 1-Introduction to Octave Introduction This assignment is meant to be a gentle introduction to Octave, the free version of Matlab. It assumes that you have no prior coding experience. Objectives Download Octave and run it or use https://octave-online.net/ Learn the basics of the Octave GUI. • Learn how to create a short executable file called an m-file (.m extension) and run it. • Learn what a data type is. • Learn how to declare variables of different data types. • Learn how to create matrices. • Learn how to use several of Octave’s functions for creating objects with random numbers. Instructions 1.) Create a file call it with the form exercise_1_first name_last name. Include the underscores in your file name. At the top of the file add the comment "“My first Octave assignment. I'm so excited, I just can't hide it." 2.) Create the following variables a = 2.3; b = -87.3; A = [1,2; 4,5]; Create a matrix 2 × 2 B using the rand() function. Create two random complex…arrow_forwardsave_compressed_image: takes a nested list and a filename (string) as input, and saves it in the compressed PGM format to a file with the given filename. If the image matrix given as input is not a valid compressed PGM image matrix, instead raise a AssertionError with an appropriate error message. >>> save_compressed_image([["0x5", "200x2"], ["111x7"]], "test.pgm.compressed") >>> fobj open("test.pgm.compressed", 'r') >>> fobj.read() = 'P2C\\n7_2\\n255\\n0x5 200x2\\n111x7\\n' >>> fobj.close() >>> image [["0x5", "200x2"], ["111x7"]] >>> save_compressed_image(image, "test.pgm") >>> image2 = >>> image True = == load_compressed_image("test.pgm") image2 • save_image: takes a nested list and a filename (string) as input. Checks the type of elements in the list If thou are intogors thon saves the posted list as a PCM imago matrix into a file with the givenarrow_forwardPlease written by computer source I want to add an if statment to my code for overtime if the number of hours are over 40 but im stuck on how to do it, This is a link for my code: https://prnt.sc/1a-IVCvrRU_m This is what I am trying to add to my code : https://prnt.sc/8g5_4YbMXF0barrow_forward
- You can download; restadata.txt : https://dosyam.org/2D1j/restdata.txt restaurant.c :https://dosyam.org/2D1i/restaurant.c Given code should be modify in C Language. Can someone help me please ? #include <stdio.h> // Do not edit these directives or add another.#include <stdlib.h>#include <string.h>#include <time.h> #define MAX 1000 // Do not edit this macro. typedef struct // Do not edit this struct.{unsigned long restaurant_id;char restaurant_name[15];char description[127];double rate;char cuisine[31];unsigned short opening_year;unsigned long capacity;char city[31];char address[63];char owner[31];} RECORD_t, *RECORD; /* DECLARE YOUR FUNCTION PROTOTYPES HERE. */void find_by_opening_year(unsigned short opening_year, RECORD *restaurant_array, unsigned long size, unsigned long start, unsigned long end, unsigned long *p_found_num, RECORD **p_found_restaurants);RECORD find_by_restaurant_name(char *restaurant_name, RECORD *restaurant_array, unsigned long size,…arrow_forwardQUESTION PROVIDED IN ATTACH IMAGE KINDLY SEE. PROVIDE OUTPUT AS IT IS SHOWN IN QUESTION. AND BELOW TEMPLATES PROVIDED CHECK THIS BEFORE MAKING SOLUTION ( main.cpp , salary.cpp ) ----------------- TEMPLATES BELOW FOR SOLUTION ----------------------- salary.cpp #include<iostream>using namespace std;class Salary{public:string name;float HRA,DA,basic;public:Salary(){}Salary(string name,float basic, float hra,float da){name=name;basic=basic;HRA=hra;DA=da; }public:void calculateSalary(int taxType){//Fill your code here}}; main.cpp #include<iostream>#include "Salary.cpp"using namespace std; int main(){string name;float Basic,HRA,DA;int choice;cout<<"Enter the Name of the employee :"<<endl;cin>>name;cout<<"Enter the Basic pay :"<<endl;cin>>Basic;cout<<"Enter the HRA percentage :"<<endl;cin>>HRA;cout<<"Enter the DA percentage :"<<endl;cin>>DA;cout<<"Enter if the tax is fixed or variable…arrow_forward8Her.e Provide the correct c++ code for below code /****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include using namespace std; #include int hextodec(char num[]) { int len = strlen(num); int base = 1; int temp = 0; for (int i=len-1; i>=0; i--) { if (num[i]>='0' && num[i]='A' && num[i]..arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education