Assignment08
.pdf
keyboard_arrow_up
School
Indiana University, Bloomington *
*We aren’t endorsed by this school
Course
505
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
4
Uploaded by ColonelWorld13096
Assignment 08
Instructions
1. Write your functions according to the signature provided below in a python(.py) file and
submit them to the autograder for evaluation.
2. The autograder has a limited number of attempts. Hence, test it thoroughly before submit-
ting it for evaluation.
3. Save your python file as text(.txt) file and submit it to the canvas.
4. If the assignment has theoretical questions, upload those answers as a pdf file on the canvas.
5. Submission on the canvas is mandatory and the canvas submitted text file should be the
same as that of the final submission of the autograder. If not, marks will be deducted.
6. No submission on canvas or no submission on autograder then marks will be deducted.
7. Access the auto grader at https://c200.luddy.indiana.edu.
Question 1
You are in charge of communications aboard a spaceship on a top-secret mission.
For security
reasons, mission control will send messages that have numeric values hidden within an array. You
know that whenever you receive an array of numbers, the hidden number is the length of the
largest subsequence such that all elements of the subsequence are exactly 7 away from at least one
other element of the subsequence. Write code to automatically translate these arrays into integers.
Examples
Input: arr = [2,9,1]
Output: 2
Explanation: the subsequence <2,9> has 2 elements that are 7 apart from each other. Thus, the
answer is 2.
Input: arr = [6,0,14,4,7,3]
Output: 3
Explanation: the subsequence <0,14,7> has 3 elements that are 7 apart from each other. Thus,
the answer is 3.
Constraints:
• Solve using hashing
• There will be no duplicate values in the input array
Function
def
translate_message(arr):
#return int
return
value
1
Question 2
A blacksmith named Gary is crafting armor for the king. He received an order to make
n
shields of
varying sizes. These orders came in an array of size
n
with each element of the list being a tuple of
the form
[a
,b]‘ where a is the height of the shield and b is the length. However, before Gary could
start crafting these orders, an evil wizard cast a spell on the list so that some of the elements were
duplicated and then flipped within the array. Now Gary needs to find how many symmetric pairs
are within the list so that he can remove the duplicates and make the correct shields for the king.
Write code that takes the list of orders and returns the size of the original list if all symmetric
parts are removed.
Examples
Input: orders = [[1,2],[2,1]]
Output: 1
Explanation: The two elements in the array are symmetric pairs to each other. So one of them
must be a duplicate. If we remove it, the list will have size of 1.
Input: orders = [[5,8], [3,2], [5,8]]
Output: 3
Explanation: There are no symmetric pairs in the list, so there are no duplicates. Thus, the size
is still 3.
Constraints:
• Solve using hashing
Function
def
find_order_size(orders):
#return int
return
order_size
Question 3
On one fine day you decided to visit the circus nearby. In that circus, all the people are playing
one game. In that game, you are displayed with a long string and you need to decide if that string
has some repetition in it. You instantly notice that the string only has 4 unique characters in it
W, X, Y, Z. Your job is to note down which strings of length 10 are repeating in the given string.
Examples
Input: circusString = "WWWWWXXXXXWWWWWXXXXXXWWWWWYYYZZZ"
Output: ["WWWWWXXXXX", "XXXXXWWWWW"]
Explanation: The given two sequences in the output array are present multiple times in the input
string and have length = 10.
2
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
You must use one other model (math/random).
arrow_forward
Which statements are not false about Python Module?
Modules in Python provides us the flexibility to organize the code in a logical way.
Modules are files containing Python definitions and statements (ex. name.py).
The code is usually well organized, easy to maintain, and developer-friendly that support the modular design approach.
Object is simply a collection of data (variables) and methods (functions) that act on those data.
arrow_forward
Hi this is my firs time so
i have homeworek i need hlep in it :
Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit.
thx
arrow_forward
In python please - all sections (there are 3 in total) except the last 3 pages included in the images, last section included in text below, thank you. Do not change the function names or given starter code in your script. Each class has different requirements, read them carefully and ask so I can comment to clarify. Do not use the exec or eval functions, nor are you allowed to use regular expressions. This includes multiple methods interacting with each other over the course of execution. All methods that output a string must return the string, not print it. If you are unable to complete a method, use the pass statement to avoid syntax errors.
Last 3 pages continued -
calculate(self) A property method that evaluates the infix expression saved in self.__expr. First convert the expression to postfix, then use a stack to evaluate the output postfix expression. You must use the Stack defined in section 1 in this method, otherwise your code will not receive credit. Input (excluding…
arrow_forward
What steps are used to save local declarations in computer memory? If it is feasible to accomplish the same result without them, there are legitimate reasons not to employ them, although none are very compelling. If reference parameters can achieve the same effects, there is absolutely no need to use value parameters. What part do value parameters play in ensuring that a computer program makes the most of your data?
arrow_forward
Local declarations are those that are stored in the computer's memory, but how are they stored? Using local declarations is unnecessary if the same goal can be accomplished without them. When reference parameters may be used in any function, why bother with value parameters? When it comes to processing programme data, how important are value parameters?
arrow_forward
Converting a Program Design to Python Code [10 marks]
This exercise should be done in the "Exercise1" file provided to you. In class, we've been drawing
up designs in English for programs we want to write. We've then used these code designs to create
programs in Python code. For now, I've given you a code design and your job is to convert the
design into Python code.
Below l'll first provide an example for you. On the left is a code design and on the right is the
associated Python code. You need not type it in if you don't want to; it's just an example of a code
design and its corresponding code.
Design:
Create a variable 'num1' and store the
number 4 in it
Code:
num1 = 4
Ask the user for a number; store this in
variable 'num2'
num2 = int(input("Enter a number:")
Add variables num1 and num2 and
total = num1 + num2
store the result in variable 'total'
Display "The total is:"
Display variable 'total'
print("The total is:")
print(total)
YOUR TASK: Convert the following code design into…
arrow_forward
f. Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit.
arrow_forward
Question 2
You must give a word count for any question part with a maximum word limit.
This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2.
You will find it useful to read through the whole question before starting to answer it.
In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting.
Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…
arrow_forward
Question 2
You must give a word count for any question part with a maximum word limit.
This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2.
You will find it useful to read through the whole question before starting to answer it.
In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting.
Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…
arrow_forward
Question 2
You must give a word count for any question part with a maximum word limit.
This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2.
You will find it useful to read through the whole question before starting to answer it.
In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting.
Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…
arrow_forward
Using JAVA language
f. Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit.
arrow_forward
Write a report (EC2_Document.pdf) to profile any of c code (it does not have to be your own).Your report should include the following:1. Description of the program code (EC2_TestCode.c) a. What are the major functions in the code?
b. Describe them briefly. i. What are the parameter(s) to the function? ii. What does it return (if any)?
2. Brief introduction to the profiler you used. a. gprof or any other profiler/tool
3. Describe your plan on how to profile the code. a. what data, parameters, etc.
4. Discuss your observations. a. profiling results based on different dataset/ parameter settings.
5. Analysis of your observations.
6. If possible, try to optimize the bottleneck function(s). Save your updated code inEC2_OptimizedTestCode.c
a. Discuss what changes you made.
b. How much improvement you got.
7. Provide the details of you test environment:
a. Operation System, Processor, RAM size, etc
arrow_forward
in c++ code
arrow_forward
Direction: Answers must be explained properly and thoroughly. You have to insert a screenshot of the results. Include the observations of your code.
Python download: https://www.python.org/downloads/ Any Python Version 3.8 and later is recommended
arrow_forward
C++
arrow_forward
you will utilize functions to provide a way to clear Python’s integrated development environment (IDLE) window. In your initial post, provide the function for achieving this task and explain the process of clearing the IDLE window. Discuss some challenges that you faced in accomplishing this task.
Note: The "cls" and "clear" commands are used to clear a terminal (i.e., a DOS prompt or terminal window).
arrow_forward
Please do it Yourself.You are supposed to write an SRS document of the system scenario given in the file named “Smart health system”. In the file the information about the system and its module which are to be made are discussed. You are supposed to make an SRS document of that system by writing only the first three sections of the SRS document.
The File: Read it
Smart Health Monitoring SystemAs the name states Smart Health Monitoring System is a smart AI that calculates almost everything you need to take care of your health. The System helps with-BMI Level,-Diet Monitoring,-Diet Suggestions,-Footstep monitoring,-Sleep Suggestions,-Water Alarm.
So the user has to just register into the system by giving his personal details and physical attributes and the rest, the system takes care of everything. The Food items with its fats, carbs and proteins level are already stored in the database and the user can also add new food, which will help the system to monitor the users diet and…
arrow_forward
The exit function still persists and does not logically exit. I don't understand.
arrow_forward
• You are to work on this activity individually.
• You are to create a Python application that applies classes and objects in Python.
• Scenario: You are to create a python application that simulates the function of a basic calculator with some additional
features. The user will select what function they would like to use in the application, after which they will input the va
they would like to use for the computation selected. The program will then compute for the output based on the give
function and return the output to the user. The user should then be able to select additional functions and input new
until they are satisfied, after which they can exit the application.
• The application should first ask for a command from the user when started, the user can do 9 different commands on
application:
。 The Calculator Features
▪ Add Two Numbers - Adds two numbers inputted from the user.
Subtract Two Numbers - Subtracts two numbers inputted from the user.
Multiply Two Numbers -…
arrow_forward
Write a pythonprogram that reads in a Python source code file and counts the occurrence of each keyword and eachidentifier (variables, class and method names) in the file using three dictionaries: one for keywords and one forvariables, and one for integer (e.g. 12,44) and string literals (e.g. “aba”, “ali”) Your program should prompt theuser to enter the Python source code filename.Keywords in Python programming language:False class finally is return None continue for lambda tryTrue def from nonlocal while and del global not with as elifif or yield assert else import pass break
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
Could you please provide me with a list of the actions that need to be taken in order to carry out an evaluation of the software's structure?
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
Related Questions
- You must use one other model (math/random).arrow_forwardWhich statements are not false about Python Module? Modules in Python provides us the flexibility to organize the code in a logical way. Modules are files containing Python definitions and statements (ex. name.py). The code is usually well organized, easy to maintain, and developer-friendly that support the modular design approach. Object is simply a collection of data (variables) and methods (functions) that act on those data.arrow_forwardHi this is my firs time so i have homeworek i need hlep in it : Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit. thxarrow_forward
- In python please - all sections (there are 3 in total) except the last 3 pages included in the images, last section included in text below, thank you. Do not change the function names or given starter code in your script. Each class has different requirements, read them carefully and ask so I can comment to clarify. Do not use the exec or eval functions, nor are you allowed to use regular expressions. This includes multiple methods interacting with each other over the course of execution. All methods that output a string must return the string, not print it. If you are unable to complete a method, use the pass statement to avoid syntax errors. Last 3 pages continued - calculate(self) A property method that evaluates the infix expression saved in self.__expr. First convert the expression to postfix, then use a stack to evaluate the output postfix expression. You must use the Stack defined in section 1 in this method, otherwise your code will not receive credit. Input (excluding…arrow_forwardWhat steps are used to save local declarations in computer memory? If it is feasible to accomplish the same result without them, there are legitimate reasons not to employ them, although none are very compelling. If reference parameters can achieve the same effects, there is absolutely no need to use value parameters. What part do value parameters play in ensuring that a computer program makes the most of your data?arrow_forwardLocal declarations are those that are stored in the computer's memory, but how are they stored? Using local declarations is unnecessary if the same goal can be accomplished without them. When reference parameters may be used in any function, why bother with value parameters? When it comes to processing programme data, how important are value parameters?arrow_forward
- Converting a Program Design to Python Code [10 marks] This exercise should be done in the "Exercise1" file provided to you. In class, we've been drawing up designs in English for programs we want to write. We've then used these code designs to create programs in Python code. For now, I've given you a code design and your job is to convert the design into Python code. Below l'll first provide an example for you. On the left is a code design and on the right is the associated Python code. You need not type it in if you don't want to; it's just an example of a code design and its corresponding code. Design: Create a variable 'num1' and store the number 4 in it Code: num1 = 4 Ask the user for a number; store this in variable 'num2' num2 = int(input("Enter a number:") Add variables num1 and num2 and total = num1 + num2 store the result in variable 'total' Display "The total is:" Display variable 'total' print("The total is:") print(total) YOUR TASK: Convert the following code design into…arrow_forwardf. Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit.arrow_forwardQuestion 2 You must give a word count for any question part with a maximum word limit. This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2. You will find it useful to read through the whole question before starting to answer it. In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…arrow_forward
- Question 2 You must give a word count for any question part with a maximum word limit. This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2. You will find it useful to read through the whole question before starting to answer it. In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…arrow_forwardQuestion 2 You must give a word count for any question part with a maximum word limit. This question tests your understanding of Block 3 Part 2 and, more generally, the problem-solving and Python programming skills that are covered by the module. The question is concerned with a variation of the flashcard problem you studied in Block 3 Part 2. You will find it useful to read through the whole question before starting to answer it. In the original flashcard problem, the cards are designed to help a user improve their familiarity with a glossary of terms. The user can ask the program to show an entry picked randomly from a glossary. When the user presses return, the program shows the definition corresponding to that entry. The user is then given the option of seeing another entry or quitting. Another common use of flashcards is to help someone learning a language practise their vocabulary. Someone learning French, for example, might have a set of cards with English words on one…arrow_forwardUsing JAVA language f. Create the principal program, which will complete the following tasks :a. Create a new Student object by reading the required details and by applying at least one type of data validation of your choice on the input. b. Read and save the list of module names and the list of module marks awarded to the student in the two assignments. c. Display the transcript of the student by calling the adequate method.d. Repeating the previous tasks until the user decides to exit.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage