Question

In: Computer Science

PYTHON COADING In this homework, we are mostly going to work with and manipulate pre-written code....

PYTHON COADING In this homework, we are mostly going to work with and manipulate pre-written code. But first, let’s practice writing a few lines of code ourselves.

(a) Create a function that raises any number to the power of 3 and fully annotate in the code itself what each line is doing. Check that your function is operating correctly (this may seem trivial now, but is good practice going forward as your programs become more complicated).

(b) Create three objects, which represent one of each of the following: a list, an array, and a tuple, each with three items.

(c) Multiply each of these three objects by three. What are the results, and why?
(d) Replace the third item in the array with the number 23. Do the same for the tuple. Show what happens. Why do you get this result?

(e) Create a range from 0 to 42 that includes every third number.

(f) Create a table with three rows and three columns, containing any kind of data (made up or real) that you like using pandas and a dictionary. Show the table, and describe the contents of the rows and columns.

Solutions

Expert Solution


Related Solutions

In Python For this programming assignment, we are going to investigate how much "work" different sorting...
In Python For this programming assignment, we are going to investigate how much "work" different sorting routines do, based on the input size and order of the data. We will record the work done by writing output CSV (comma separated value) files and creating various plots using matplotlib. Note: for this assignment, do not use Jupyter Notebook to code your solution. Use standard .py files and save your output to .csv and .png files (see the program details below for...
Problem 1: python For the first problem of this homework, we’re going to try something a...
Problem 1: python For the first problem of this homework, we’re going to try something a little different. I’ve created the start of a file, which you’ll edit to finish the assignment: count_words_in_the_raven.py The program has three functions in it. I’ve written all of break_into_list_of_words()--DO NOT CHANGE THIS ONE. All it does is break the very long poem into a list of individual words. Some of what it's doing will not make much sense to you until we get to...
Excel Homework: We are going to start working on sample statistics—that is, on measures we can...
Excel Homework: We are going to start working on sample statistics—that is, on measures we can sue to describe a sample. The two that we will learn about today are histograms, and 5 number summaries (which can be represented using box-plots). 1. You are designing a game, and considering having players roll a six-sided die and a 20-sided die, and add the values of each die. To get a picture of what happens when someone rolls dice like that, you...
For Homework 4, we are going to present the user with a series of menus, accept...
For Homework 4, we are going to present the user with a series of menus, accept as input the action they wish to take, and act appropriately. You must practice basic input validation to ensure that the menu option they chose is valid. Create “CPS132 Homework 4” project in Eclipse Create “Homework4.py” file Download "Homework4_incomplete.py" Paste the text into "Homeworkpy" Make sure to fill in the appropriate information in the header including your name, username, due date, Homework #4, and...
In this homework, we will write the code that will take an expression (input) from the...
In this homework, we will write the code that will take an expression (input) from the user in infix notation and convert that to corresponding postfix notation and evaluate its value. Task 0: Use the starter code to start. All the needed functions and their functionalities are given in the starter code. Task 1: Complete the startercodeinfixtopostfix.c file Task 2: Complete the startercodeevaluatepostfix.c file Sample Input/Output: (Infix to postfix) Input: (A + B)*C-D*E Output: A B + C * D...
For this homework we are going to walk you through creating a class. Lets look at...
For this homework we are going to walk you through creating a class. Lets look at a pizza restaurant and create a class for this. We will call our class pizza. The goal for every class is to include everything that has to happen for that class in 1 place. So whenever we create a class we need to think of what the nouns or variables will be for that class and then what the actions or methods will be...
(Python or C++) We are going to implement the following scheduling algorithms that we discussed in...
(Python or C++) We are going to implement the following scheduling algorithms that we discussed in class: 1. First-Come First-Served (FCFS) 2. Shortest Remaining Time First (SRTF) 3. Highest Response Ratio Next (HRRN) 4. Round Robin, with different quantum values (RR) We are interested to compute the following metrics, for each experiment: _ The average turnaround time _ The total throughput (number of processes done per unit time) _ The CPU utilization _ The average number of processes in the...
I need this code to be written in Python: Given a dataset, D, which consists of...
I need this code to be written in Python: Given a dataset, D, which consists of (x,y) pairs, and a list of cluster assignments, C, write a function centroids(D, C) that computes the new (x,y) centroid for each cluster. Your function should return a list of the new cluster centroids, with each centroid represented as a list of x, y: def centroid(D, C):
Please finish this code and make it work. This is my homework and my professor wont...
Please finish this code and make it work. This is my homework and my professor wont allow me to change the code in main, it's a set of huge numbers need to sort by radixsort with bit operation. #include <iostream> using namespace std; void radixLSD_help(int *items, int length, int bit) {    // – Count number of items for each bucket.    // – Figure out where each bucket should be stored (positions // of the first and last element...
Using python code Developed a program to get students homework, midterm, and final exam grades and...
Using python code Developed a program to get students homework, midterm, and final exam grades and compute their average grades display average grade as a number and give them letter gardes. For this homework, I would like you to modify your to do the following. Student grades MUST be between 0 and 100. If students input any number that is not in this range , program must keep asking to enter the correct number. Once student input correct grade, program...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT