Lab_Assignment_2 - 2
.html
keyboard_arrow_up
School
Pennsylvania State University *
*We aren’t endorsed by this school
Course
200
Subject
Computer Science
Date
Dec 6, 2023
Type
html
Pages
30
Uploaded by GeneralSummer13484
DS200: Introduction to Data Sciences
¶
Lab Assignment 2: Loops, Tables, Visualizations (2
points)
¶
First, let's import the Python modules needed for this assignment. Please remember
that you need to import the modules again every time when you restart your kernel,
runtime, or session.
In [1]:
from datascience import *
import matplotlib
matplotlib.use('Agg')
%matplotlib inline
import matplotlib.pyplot as plots
plots.style.use('fivethirtyeight')
import numpy as np
Part 1: Random Choice (Chapter 9)
¶
NumPy has a function
np.random.choice(...)
that can be used to pick one item at
random from a given array. It is equally likely to pick any of the items in the array. Here
is an example. Imagine that one day, when you get home after a long day, you see a
hot bowl of nachos waiting on the dining table! Let's say that whenever you take a
nacho from the bowl, it will either have only
cheese
, only
salsa
,
both
cheese and
salsa, or
neither
cheese nor salsa (a sad tortilla chip indeed). Let's try and simulate
taking nachos from the bowl at random using the function,
np.random.choice(...)
.
Run the cell below three times, and observe how the results may differ between these
runs.
In [2]:
nachos = make_array('cheese', 'salsa', 'both', 'neither')
np.random.choice(nachos)
Out[2]:
'cheese'
In [3]:
np.random.choice(nachos)
Out[3]:
'cheese'
In [4]:
np.random.choice(nachos)
Out[4]:
'both'
To repeat this process multiple times, pass in an int
n
as the second argument. By
default,
np.random.choice
samples
with replacement
and returns an
array
of items.
Run the next cell to see an example of sampling with replacement 10 times from the
nachos
array.
In [5]:
np.random.choice(nachos, 10)
Out[5]:
array(['salsa', 'cheese', 'salsa', 'neither', 'salsa', 'cheese', 'both',
'both', 'neither', 'cheese'],
dtype='<U7')
Next, let's use
np.random.choice
to simulate one roll of a fair die. The following code
cell gives a statement that simulates rolling a die once and records the number of
spots on the die in a variable
x
. You can run it multiple times to see how variable the
results are.
In [6]:
x = np.random.choice(np.arange(1, 7))
x
Out[6]:
6
Problem 1: Rolling a Fair Die 10 Times (0.25 points)
¶
Write an expression that rolls a die 10 times and return the results in an array.
In [7]:
# write code for Problem 1 in this cell
x = np.random.choice(np.arange(1, 7), 10)
x
Out[7]:
array([6, 3, 1, 5, 5, 3, 4, 6, 2, 5])
Part 2: Python Loops (Chapter 9.2)
¶
Iteration
¶
It is often the case in programming – especially when dealing with randomness – that
we want to repeat a process multiple times. For example, let's consider the game of
betting on one roll of a die with the following rules:
•
If the die shows 1 or 2 spots, my net gain is -1 dollar.
•
If the die shows 3 or 4 spots, my net gain is 0 dollars.
•
If the die shows 5 or 6 spots, my net gain is 1 dollar.
The function
bet_on_one_roll
takes no argument. Each time it is called, it simulates
one roll of a fair die and returns the net gain in dollars.
In [8]:
def bet_on_one_roll():
"""Returns my net gain on one bet"""
x = np.random.choice(np.arange(1, 7))
# roll a die once and record the number of
spots
if x <= 2:
return -1
elif x <= 4:
return 0
elif x <= 6:
return 1
Playing this game once is easy:
In [9]:
bet_on_one_roll()
Out[9]:
-1
To get a sense of how variable the results are, we have to play the game over and over
again. We could run the cell repeatedly, but that's tedious, and if we wanted to do it a
thousand times or a million times, forget it.
A more automated solution is to use a
for
statement to loop over the contents of a
sequence. This is called
iteration
. A
for
statement begins with the word
for
, followed
by a name we want to give each item in the sequence, followed by the word
in
, and
ending with an expression that evaluates to a sequence. The
indented
body of the
for
statement is executed once
for each item in that sequence
. The code cell below
gives an example.
In [10]:
for animal in make_array('cat', 'dog', 'rabbit'):
print(animal)
cat
dog
rabbit
It is helpful to write code that exactly replicates a
for
statement, without using the
for
statement. This is called
unrolling
the loop.
A
for
statement simply replicates the code inside it, but before each iteration, it
assigns a new value from the given sequence to the name we chose. For example,
here is an unrolled version of the loop above.
In [11]:
animal = make_array('cat', 'dog', 'rabbit').item(0)
print(animal)
animal = make_array('cat', 'dog', 'rabbit').item(1)
print(animal)
animal = make_array('cat', 'dog', 'rabbit').item(2)
print(animal)
cat
dog
rabbit
Notice that the name
animal
is arbitrary, just like any name we assign with
=
.
Here we use a
for
statement in a more realistic way: we print the results of betting
five times on the die as described earlier. This is called
simulating
the results of five
bets. We use the word
simulating
to remind ourselves that we are not physically rolling
dice and exchanging money but using Python to mimic the process.
To repeat a process
n
times, it is common to use the sequence
np.arange(n)
in the
for
statement. It is also common to use a very short name for each item. In our code
we will use the name
i
to remind ourselves that it refers to an item.
In [12]:
for i in np.arange(5):
print(bet_on_one_roll())
1
1
-1
1
0
In this case, we simply perform exactly the same (random) action several times, so the
code in the body of our
for
statement does not actually refer to
i
.
The iteration variable
i
can be used in the indented body of a loop. The code cell
below gives an example.
In [13]:
nums = np.arange(5)
sum_nums = 0
for i in nums:
sum_nums = sum_nums + i
print('Sum of the first four positive integers is: ' + str(sum_nums))
Sum of the first four positive integers is: 10
Problem 2A: Iterating over a Custom Array (0.25 points)
¶
Create an array that contains the items "Apple", "Banana", "Kiwi", and "Orange". Write
a
for
loop to iterate over the items in the array and print them one by one.
In [14]:
# write code for Problem 2A in this cell
fruits = make_array('Apple', 'Banana', 'Kiwi', 'Orange')
for item in fruits:
print(item)
Apple
Banana
Kiwi
Orange
Augmenting Arrays
¶
While the
for
statement above does simulate the results of five bets, the results are
simply printed and are not in a form that we can use for computation. An array of
results would be more useful. Thus a typical use of a
for
statement is to create an
array of results, by augmenting the array each time.
The
append
method in
NumPy
helps us do this. The call
np.append(array_name,
value)
evaluates to a new array that is
array_name
augmented by
value
. When you
use
append
, keep in mind that all the entries of an array must have the same type.
In [15]:
pets = make_array('Cat', 'Dog')
np.append(pets, 'Another Pet')
Out[15]:
array(['Cat', 'Dog', 'Another Pet'],
dtype='<U11')
This keeps the array
pets
unchanged:
In [16]:
pets
Out[16]:
array(['Cat', 'Dog'],
dtype='<U3')
But often while using
for
loops it will be convenient to mutate an array – that is,
change it – when augmenting it. This is done by assigning the augmented array to the
same name as the original.
In [17]:
pets = np.append(pets, 'Another Pet')
pets
Out[17]:
array(['Cat', 'Dog', 'Another Pet'],
dtype='<U11')
Problem 2B: Creating a New Array by Augmenting (0.25 points)
¶
Use
np.append
to create an array with letters
A
through
E
, by adding the letters one by
one to the array, starting from an empty array.
In [18]:
# write code for Problem 2B in this cell
alphabets = make_array()
alphabets = np.append(alphabets, 'A')
alphabets = np.append(alphabets, 'B')
alphabets = np.append(alphabets, 'C')
alphabets = np.append(alphabets, 'D')
alphabets = np.append(alphabets, 'E')
Example: Betting on 5 Rolls
¶
We can now simulate five bets on the die and collect the results in an array that we will
call the
collection array
. We will start out by creating an empty array for this, and then
append the outcome of each bet. Notice that the body of the
for
loop contains two
statements. Both statements are executed for each item in the given sequence.
In [19]:
outcomes = make_array()
for i in np.arange(5):
outcome_of_bet = bet_on_one_roll()
outcomes = np.append(outcomes, outcome_of_bet)
outcomes
Out[19]:
array([ 0.,
1.,
1.,
1.,
1.])
As shown in the example above, the
indented
body of a
for
statement can contain
multiple
statements and each of the statements is executed for each item in the
given sequence.
By capturing the results in an array, we have given ourselves the ability to use array
methods to do computations. For example, we can use
np.count_nonzero
to count the
number of times money changed hands.
In [20]:
np.count_nonzero(outcomes)
Out[20]:
4
Betting on 300 Rolls
¶
Iteration is a powerful technique. For example, we can see the variation in the results
of 300 bets by running
bet_on_one_roll
for 300 times intead of five.
In [21]:
outcomes = make_array()
for i in np.arange(300):
outcome_of_bet = bet_on_one_roll()
outcomes = np.append(outcomes, outcome_of_bet)
outcomes
Out[21]:
array([ 1.,
0.,
0.,
1.,
1.,
1., -1.,
0., -1.,
1., -1.,
1.,
1.,
1., -1.,
1.,
1.,
1.,
0.,
0.,
1., -1., -1.,
1.,
0.,
0.,
0., -1.,
0.,
1.,
0., -1., -1.,
1.,
0.,
0.,
1.,
0., -1.,
0.,
0., -1.,
1.,
1.,
0.,
1., -1., -1.,
1.,
1., -1., -1.,
0.,
0.,
1., -1.,
1.,
1.,
1.,
0., -1.,
1.,
1., -1.,
0.,
1.,
1., -1.,
0.,
1.,
0., -1.,
0.,
0.,
0.,
1.,
0.,
1.,
0.,
1.,
0.,
1., -1., -1., -1.,
0., -1.,
1.,
1., -1., -1.,
-1.,
0.,
1.,
0., -1., -1., -1.,
1.,
0.,
1.,
1.,
0., -1.,
-1., -1.,
1.,
0.,
1., -1., -1.,
1., -1., -1., -1.,
0.,
1.,
-1., -1.,
1.,
1., -1., -1., -1.,
0.,
1., -1., -1., -1.,
1.,
1.,
0.,
1.,
0.,
1.,
1.,
1., -1.,
1.,
0.,
1., -1.,
0.,
0.,
1., -1.,
0.,
1.,
0.,
0.,
1.,
1., -1.,
0.,
1.,
1.,
0.,
1., -1.,
1., -1.,
0., -1., -1., -1., -1., -1., -1., -1.,
1., -1., -1.,
1., -1.,
1.,
1., -1.,
1.,
0.,
1.,
1.,
1.,
0., -1.,
0.,
1., -1., -1., -1.,
0.,
0.,
1.,
0.,
0.,
0.,
0., -1.,
1., -1.,
1., -1.,
0., -1.,
1.,
0.,
1.,
0.,
1.,
-1.,
0., -1.,
0.,
0.,
1.,
1., -1., -1., -1.,
0., -1., -1.,
0., -1.,
0.,
1., -1.,
1., -1.,
1.,
0.,
1., -1.,
1.,
1.,
0.,
1.,
0.,
0.,
1., -1., -1.,
1.,
0., -1.,
1.,
0.,
1.,
1.,
0.,
0.,
0.,
0.,
1.,
0., -1.,
0.,
1.,
1.,
1., -1.,
0.,
1.,
1., -1.,
0.,
1.,
0.,
1.,
0.,
1., -1.,
0.,
1.,
1.,
1., -1., -1.,
0.,
1.,
1.,
0.,
0., -1.,
0.,
1.,
0.,
-1.,
0., -1.,
1.,
1., -1.,
0.,
0.,
1.,
0.,
1.,
0.,
1.,
1.])
The array
outcomes
now contains the results of all 300 bets.
In [22]:
len(outcomes)
Out[22]:
300
In [23]:
for i in np.arange(5):
print(i)
0
1
2
3
4
Problem 2C: Probability of Non-Zero Gain (0.25 points)
¶
Write an expression that uses the 300 simulated outcomes to estimate the probability
that our net gain for a bet is not zero.
In [24]:
# write code for Problem 2C in this cell
outcomes = make_array()
for i in np.arange(300):
outcome_of_bet = bet_on_one_roll()
outcomes = np.append(outcomes, outcome_of_bet)
probability = np.count_nonzero(outcomes) / 300
print(probability)
0.6533333333333333
Part 3: Selecting Rows from Table (Chapter 6.2)
¶
In Lab Assignment 1, we practiced the Table method
take
, which takes a specific set of
rows from a table. Its argument is a row index or an array of indices, and it creates a
new table consisting of only those rows.
For example, if we wanted just the first row of movies, we could use take as follows.
In [25]:
movies = Table.read_table('IMDB_movies.csv')
movies.take(0)
Out[25]:
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
PROGRAMMING LANGUAGE: C++
Please test the code first before uploading here in bartleby. The expected outcome for each of the test case is also given in the screenshot. Follow accordingly. Thanks
arrow_forward
Please help me with the assignment below
The assignment:
Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.
arrow_forward
C+++ proram An organization is going to design a small database to store the records of students. They hire you in the development team and assign a small module of the project. You have to store the firstName, LastName, address, sapId, semester, and CGPA of all the students in a class. You are supposed to use 2D character array to store firstName and lastName. To test the working of your module you can fix the class size to 15. Pass these arrays into a displayRecord function which display complete information of all the students in a class. Create a function updateRecord which receives the sapId and search that whether this sapId exist in the array. If it exists than change the firstName, address and CGPA of that student otherwise display a simple message that "record does not exist
arrow_forward
pizzaStats Assignment Description
For this assignment, name your R file pizzaStats.R
For all questions you should load tidyverse and lm.beta. You should not need to use any other libraries.
Load tidyverse with
suppressPackageStartupMessages(library(tidyverse))
Load lm.beta withsuppressPackageStartupMessages(library(lm.beta))
Run a regression predicting whether or not wine was ordered from temperature, bill, and pizza.
Assign the coefficients of the summary of the model to Q1. The output should look something like this:
Estimate Std. Error z value Pr(>|z|)(Intercept) -1.09 1.03 -1.06 0.29temperature -0.04 0.01 -3.20 0.00bill 0.03 0.01 3.75 0.00pizzas 0.19 0.06 3.27 0.00
Here is the link of the pizza.csv https://drive.google.com/file/d/1_m2TjPCkPpMo7Z2Vkp32NiuZrXBxeRn6/view?usp=sharing
arrow_forward
7-2 Discussion: Interpreting Multiple Regression Models
Previous Next
In this discussion, you will apply the statistical concepts and techniques covered in this week's reading about multiple regression. You will not be completing work in Jupyter Notebook this week. Instead, you will be interpreting output from your Python scripts for the Module Six discussion. If you did not complete the Module Six discussion, please complete that before working on this assignment.
Last week's discussion involved development of a multiple regression model that used miles per gallon as a response variable. Weight and horsepower were predictor variables. You performed an overall F-test to evaluate the significance of your model. This week, you will evaluate the significance of individual predictors. You will use output of Python script from Module Six to perform individual t-tests for each predictor variable. Specifically, you will look at Step 5 of the Python script to answer…
arrow_forward
Needs to be done in Assembly for Raspberry Pi 3B.
arrow_forward
python:
def pokehelp(poke_name, stat_min): """ Question 4 - API
You are looking for a Pokemon that can help you with your programming homework. Since Porygon is made of code, you decide to look into the species. Using the given API, return a dictionary that returns the name of each of Porygon's stats with a base stat GREATER THAN the given number, mapped to their value. Do not hardcode Porygon's stats into the results! It is not the only test case.
Base URL: https://pokeapi.co/
Endpoint: api/v2/pokemon/{poke_name}
Args: Pokemon name (str), stat minimum (int) Returns: Dictonary of stats
>>> pokehelp("porygon", 65) {'defense': 70, 'special-attack': 85, 'special-defense': 75}
>>> pokehelp("koraidon", 100) {'attack': 135, 'defense': 115, 'speed': 135}
""" # pprint(pokehelp("porygon", 65)) # pprint(pokehelp("koraidon", 100))
arrow_forward
python:
def typehelper(poke_name): """ Question 5 - API
Now that you've acquired a new helper, you want to take care of them! Use the provided API to find the type(s) of the Pokemon whose name is given. Then, for each type of the Pokemon, map the name of the type to a list of all types that do double damage to that type. Note: Each type should be considered individually.
Base URL: https://pokeapi.co/
Endpoint: api/v2/pokemon/{poke_name}
You will also need to use a link provided in the API response.
Args: Pokemon name (str)
Returns: Dictionary of types
Hint: You will have to run requests.get() multiple times!
>>> typehelper("bulbasaur") {'grass': ['flying', 'poison', 'bug', 'fire', 'ice'], 'poison': ['ground', 'psychic']}
>>> typehelper("corviknight") {'flying': ['rock', 'electric', 'ice'], 'steel': ['fighting', 'ground', 'fire']}
"""
# pprint(typehelper("bulbasaur"))#…
arrow_forward
python only
define the following function:
This function must reset the value of every task in a checklist to False. It accept just one parameter: the checklist object to reset, and it must return the (now modified) checklist object that it was given.
Define resetChecklist with 1 parameter
Use def to define resetChecklist with 1 parameter
Use a return statement
Within the definition of resetChecklist with 1 parameter, use return _in at least one place.
Use any kind of loop
Within the definition of resetChecklist with 1 parameter, use any kind of loop in at least one place.
arrow_forward
Must be done in C#
Rare Collection. We can make arrays of custom objects just like we’vedone with ints and strings. While it’s possible to make both 1D and 2D arrays of objects(and more), for this assignment we’ll start you out with just one dimensional arrays.Your parents have asked you to develop a program to help them organize the collectionof rare CDs they currently have sitting in their car’s glove box. To do this, you will firstcreate an AudioCD class. It should have the following private attributes. String cdTitle String[4] artists int releaseYear String genre float conditionYour class should also have the following methods: Default Constructor: Initializes the five attributes to the following default values:◦ cdTitle = “”◦ artists = {“”, “”, “”, “”}◦ releaseYear = 1980◦ genre = “”◦ condition = 0.0 Overloaded Constructor: Initializes the five attributes based on values passedinto the formal parameters◦ If condition is less than 0.0 or greater than 5.0, set it equal to…
arrow_forward
SUBJECT: OOPPROGRAMMING LANGUAGE: C++
ADD SS OF OUTPUT TOO.
Create a class Student with attributes StudentName, Enrollment, semester, section, course MarksObtained and Grade. Write appropriate constructors, get and set functions for data members.
Read data from file and print number of Grade occurrences in the following format:
A grade: 2
B grade: 1
C grade: 3
D grade: 2
F grade: 3
arrow_forward
Write a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this:
Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by…
arrow_forward
What is the index of the median-of-3 for the following list.
[69, 24, 97, 12, 62, 64, 17, 65, 70, 28]
Notes:
• Your answer should be a single valid, non-negative, literal Python int value. For example, 123 is a valid int literal.
• This question is asking about before any partition operation is carried out.
• This is not asking for the median-of-3 value.
• You can pre-check your answer (to check it's a valid, non-negative, literal int).
Answer: (penalty regime: 10, 20, ... %)
Precheck
Check
arrow_forward
What is the difference between 'delete' and 'deletel' in C++?
Select one:
a.delete is the correct operator, but deletel operator does not exist
b.delete is used to delete automatic objects whereas deletel is used to delete pointer objects
c.delete is used to delete single dynamic object whereas deletel is used to delete dynamic array objects
d.delete is a keyword whereas delete] is an identifier
arrow_forward
Java programming
please type the code
For this problem set, you will submit a single java file named Homework.java. You are supposed to add the functions described below to your Homework class. The functional signatures of the functions you create must exactly match the signatures in the problem titles. You are not allowed to use any 3rd party libraries in the homework assignment nor are you allowed to use any dependencies from the java.util package besides the Pattern Class. When you hava completed your homework, upload the Homework.java file to Grader Than. All tests will timeout and fail if your code takes longer than 10 seconds to complete.
ProtectedFunction(string, int)
This is a protected non-static function that takes a String and an int as its arguments and returns nothing.
You don't need to put any code in this function, you may leave the function's code empty. Don't overthink this problem. This is to test your knowledge on how to create a non-static protected function.…
arrow_forward
java programming
please type the code
For this problem set, you will submit a single java file named Homework.java. You are supposed to add the functions described below to your Homework class. The functional signatures of the functions you create must exactly match the signatures in the problem titles. You are not allowed to use any 3rd party libraries in the homework assignment nor are you allowed to use any dependencies from the java.util package besides the Pattern Class. When you hava completed your homework, upload the Homework.java file to Grader Than. All tests will timeout and fail if your code takes longer than 10 seconds to complete.
PrivateFunction()
This is a private non-static function that takes no arguments and returns an integer.
You don't need to put any code in this function, you may leave the function's code empty. Don't overthink this problem. This is to test your knowledge on how to create a non-static private function.
Arguments:
returns int - You may…
arrow_forward
Java you should have one homework.java file
For this problem set, you will submit a single java file named Homework.java. You are supposed to add the functions described below to your Homework class. The functional signatures of the functions you create must exactly match the signatures in the problem titles. You are not allowed to use any 3rd party libraries in the homework assignment nor are you allowed to use any dependencies from the java.util package besides the Pattern Class. When you hava completed your homework, upload the Homework.java file to Grader Than. All tests will timeout and fail if your code takes longer than 10 seconds to complete.
privateFunction()
This is a private non-static function that takes no arguments and returns an integer.
You don't need to put any code in this function, you may leave the function's code empty. Don't overthink this problem. This is to test your knowledge on how to create a non-static private function.
Arguments:
returns int - You may…
arrow_forward
Problem 1 – Adding contactsIn this problem, you will create the skeleton for your entire assignment. In the next problems, you will add more functionality to your program.Our goal on this problem is to create a Rolodex to store names and e-mails (using 1D or 2D arrays, you can choose). The Rolodex can store up to 256 contacts. The Rolodex will store the contact's name as one String and the contact's e-mail as another String.Your application will work as follows:1. Upon starting, it will greet the user and prompt the user to select an option (an integer)2. There are three options in problem 1:1 – to add contactnote: If the Rolodex is full, i.e. there are 256 contacts stored, this option should print: "Roldex is Full" and ask the user to input a new option5 – to print all contacts0 – to exitIf the user inputs an incorrect value, the program should prompt for an option againIf the users select option 1:1. The application will then ask for the contact's name and e-mail (see the example for…
arrow_forward
Project in Java programming language :
Choose an enterprise and do a business description of it. 1-2 pages.
Create all classes for entities.
All classes must have at least a constructor, get and set methods for all private
variables and a toString method.
Create classes also for connection entities (e.g. orders, reservations, etc.)
All information should be saved in files. When opening the program, all information from
files must be loaded in array lists. Use an array list for every class.
The program must have at least one menu where the user can choose the operations to
work.
You should at least have one class that inherits from another class. You should have at
least one interface that is extended by at least 2 classes. You must use the interface
methods in your program.
You are allowed to use the GUI for this project. If not use JOptionPane
You are allowed to use databases, instead of files.
arrow_forward
For this assignment, you must implement the Data Encryption Standard (DES) algorithm with
any programming language that you are comfortable with. The recommendation is to use C/C++
or Java. You can accomplish this assignment individually or by forming a team of 2 students.
You can utilize the publically available tables/functions in order to implement the DES. You can
find these permutation tables/functions in some reference books or over the Internet.
You algorithm should get a plaintext as well as a "secret key" from the user and then perform
encryption (generating the ciphertext from the plaintext) and decryption (generating the original
plaintext from the ciphertext).
You can also select any "mode of operations that you want. All the necessary technical
materials are available in the posted lectures on Canvas.
You must submit all related files in a zip file on Canvas (just one file for each group, submitted
by the group leader). Make sure to include a "ReadMe.txt" file so that I…
arrow_forward
Please explains in details the meaning of 2 attached file?
(attached file was running with Python Jupyter Notebook)
arrow_forward
Your understanding of importing modules, using lists and dictionaries and creating objects from a class will be exercised in this lab.
Be prepared to use your solution for the “Classes” lab (see Blackboard for the link) where you wrote the PlayingCard class.
In this lab, you will have to generate a random list of PlayingCard objects for where the suit and rank combinations of each card are randomly choosen. Using this list of randomly created playing cards, you will use dictionaries and lists to store important data about these playing cards, particularly the frequency distribution of each rank-suit combination you created (e.g. like if 10 queen of hearts cards are generated and counted.)
Thanks to the clearly described interface used to communicate to any PlayingCard object, specifically the get_rank() and get_suit() methods, you can just import your “Classes” lab as a module and use your previously written code!
Note: You’ll definitely need to make sure your solutions work for this…
arrow_forward
• Download Labl17_q2.cpp from Canvas. Read the given code. The Arr class's purpose is to
store and perform operations on an array. In C++, a basic array doesn't keep track of its own
size. That's why when we pass an array to a function, we often pass an accompanying integer.
• The Arr class we implement will hold the array as well as perform operations on the array such
as "filling" the array with a stated value.
• When we declare an array, we specify its datatype. We can have arrays of integers, arrays of
strings, etc. Because we can have arrays of many distinct types, we will implement our Arr
class as a class template.
template
The first template parameter T refers to the datatype of the array. The second parameter LENGTH
refers to the array's maximum number of elements.
Arrcint, 5> myIntArr;
Arrestring, 4> myStrArr;
• The first statement creates an int array called myIntarr with a capacity of 7 elements. When
this templated class is created, T will be an int and LENGTH (always an…
arrow_forward
Write Java Code (please don't copy wrong answer)
Implementation of a Disk-based Buffer Pool
A buffer pool is an area of main memory that has been allocated for the purpose of caching datablocks as they are read from disk. The main purpose of a buffer pool is to minimize disk I/O.Tasks: Implement a disk-based buffer pool application based on the below three buffer poolreplacement schemes: FIFO (first in, first out), LRU (least recently used), and LFU (Leastfrequently used) buffer pool replacement strategies.FIFO (First In, First Out): the oldest data block in the buffer pool is replaced.LRU (Least Recently Used): the least recently accessed data block in the buffer pool is replaced.LFU (Least Frequently Used): the least frequently accessed data block in the buffer pool isreplaced.Initially, the buffer pool is free. Disk blocks are numbered consecutively from the beginning ofthe file with the first block numbered as 0. When I execute your program,First, it asks the user to input the…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- PROGRAMMING LANGUAGE: C++ Please test the code first before uploading here in bartleby. The expected outcome for each of the test case is also given in the screenshot. Follow accordingly. Thanksarrow_forwardPlease help me with the assignment below The assignment: Make a telephone lookup program. Read a data set of 1,000 names and telephone numbers from a file that contains the numbers in random order. Handle lookups by name and also reverse lookups by phone number. Use a binary search for both lookups. This assignment needs a resource class and a driver class. The resource class and the driver class will be in two separate files. The driver class needs to have only 5 or 7 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.arrow_forwardC+++ proram An organization is going to design a small database to store the records of students. They hire you in the development team and assign a small module of the project. You have to store the firstName, LastName, address, sapId, semester, and CGPA of all the students in a class. You are supposed to use 2D character array to store firstName and lastName. To test the working of your module you can fix the class size to 15. Pass these arrays into a displayRecord function which display complete information of all the students in a class. Create a function updateRecord which receives the sapId and search that whether this sapId exist in the array. If it exists than change the firstName, address and CGPA of that student otherwise display a simple message that "record does not existarrow_forward
- pizzaStats Assignment Description For this assignment, name your R file pizzaStats.R For all questions you should load tidyverse and lm.beta. You should not need to use any other libraries. Load tidyverse with suppressPackageStartupMessages(library(tidyverse)) Load lm.beta withsuppressPackageStartupMessages(library(lm.beta)) Run a regression predicting whether or not wine was ordered from temperature, bill, and pizza. Assign the coefficients of the summary of the model to Q1. The output should look something like this: Estimate Std. Error z value Pr(>|z|)(Intercept) -1.09 1.03 -1.06 0.29temperature -0.04 0.01 -3.20 0.00bill 0.03 0.01 3.75 0.00pizzas 0.19 0.06 3.27 0.00 Here is the link of the pizza.csv https://drive.google.com/file/d/1_m2TjPCkPpMo7Z2Vkp32NiuZrXBxeRn6/view?usp=sharingarrow_forward7-2 Discussion: Interpreting Multiple Regression Models Previous Next In this discussion, you will apply the statistical concepts and techniques covered in this week's reading about multiple regression. You will not be completing work in Jupyter Notebook this week. Instead, you will be interpreting output from your Python scripts for the Module Six discussion. If you did not complete the Module Six discussion, please complete that before working on this assignment. Last week's discussion involved development of a multiple regression model that used miles per gallon as a response variable. Weight and horsepower were predictor variables. You performed an overall F-test to evaluate the significance of your model. This week, you will evaluate the significance of individual predictors. You will use output of Python script from Module Six to perform individual t-tests for each predictor variable. Specifically, you will look at Step 5 of the Python script to answer…arrow_forwardNeeds to be done in Assembly for Raspberry Pi 3B.arrow_forward
- python: def pokehelp(poke_name, stat_min): """ Question 4 - API You are looking for a Pokemon that can help you with your programming homework. Since Porygon is made of code, you decide to look into the species. Using the given API, return a dictionary that returns the name of each of Porygon's stats with a base stat GREATER THAN the given number, mapped to their value. Do not hardcode Porygon's stats into the results! It is not the only test case. Base URL: https://pokeapi.co/ Endpoint: api/v2/pokemon/{poke_name} Args: Pokemon name (str), stat minimum (int) Returns: Dictonary of stats >>> pokehelp("porygon", 65) {'defense': 70, 'special-attack': 85, 'special-defense': 75} >>> pokehelp("koraidon", 100) {'attack': 135, 'defense': 115, 'speed': 135} """ # pprint(pokehelp("porygon", 65)) # pprint(pokehelp("koraidon", 100))arrow_forwardpython: def typehelper(poke_name): """ Question 5 - API Now that you've acquired a new helper, you want to take care of them! Use the provided API to find the type(s) of the Pokemon whose name is given. Then, for each type of the Pokemon, map the name of the type to a list of all types that do double damage to that type. Note: Each type should be considered individually. Base URL: https://pokeapi.co/ Endpoint: api/v2/pokemon/{poke_name} You will also need to use a link provided in the API response. Args: Pokemon name (str) Returns: Dictionary of types Hint: You will have to run requests.get() multiple times! >>> typehelper("bulbasaur") {'grass': ['flying', 'poison', 'bug', 'fire', 'ice'], 'poison': ['ground', 'psychic']} >>> typehelper("corviknight") {'flying': ['rock', 'electric', 'ice'], 'steel': ['fighting', 'ground', 'fire']} """ # pprint(typehelper("bulbasaur"))#…arrow_forwardpython only define the following function: This function must reset the value of every task in a checklist to False. It accept just one parameter: the checklist object to reset, and it must return the (now modified) checklist object that it was given. Define resetChecklist with 1 parameter Use def to define resetChecklist with 1 parameter Use a return statement Within the definition of resetChecklist with 1 parameter, use return _in at least one place. Use any kind of loop Within the definition of resetChecklist with 1 parameter, use any kind of loop in at least one place.arrow_forward
- Must be done in C# Rare Collection. We can make arrays of custom objects just like we’vedone with ints and strings. While it’s possible to make both 1D and 2D arrays of objects(and more), for this assignment we’ll start you out with just one dimensional arrays.Your parents have asked you to develop a program to help them organize the collectionof rare CDs they currently have sitting in their car’s glove box. To do this, you will firstcreate an AudioCD class. It should have the following private attributes. String cdTitle String[4] artists int releaseYear String genre float conditionYour class should also have the following methods: Default Constructor: Initializes the five attributes to the following default values:◦ cdTitle = “”◦ artists = {“”, “”, “”, “”}◦ releaseYear = 1980◦ genre = “”◦ condition = 0.0 Overloaded Constructor: Initializes the five attributes based on values passedinto the formal parameters◦ If condition is less than 0.0 or greater than 5.0, set it equal to…arrow_forwardSUBJECT: OOPPROGRAMMING LANGUAGE: C++ ADD SS OF OUTPUT TOO. Create a class Student with attributes StudentName, Enrollment, semester, section, course MarksObtained and Grade. Write appropriate constructors, get and set functions for data members. Read data from file and print number of Grade occurrences in the following format: A grade: 2 B grade: 1 C grade: 3 D grade: 2 F grade: 3arrow_forwardWrite a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this: Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by…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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education