Section 1
.pdf
keyboard_arrow_up
School
Southern New Hampshire University *
*We aren’t endorsed by this school
Course
140 - X625
Subject
Computer Science
Date
Apr 3, 2024
Type
Pages
2
Uploaded by DeaconCaterpillar4154 on coursehero.com
Students:
Section 1.2 is a part of 1 assignment:
1-3 zyBooks Participation Activities
Includes:
PA
1.2 Programming using Python
Python interpreter
The Python interpreter
is a computer program that executes code written in the Python programming language. An
interactive interpreter
is a program that allows the user to execute one line of code at a time.
Code
is a common word for the textual representation of a program (and hence programming is also called coding
). A
line
is a row of text.
The interactive interpreter displays a prompt
("
>>>
") that indicates the interpreter is ready to accept code. The user types a
line of Python code and presses the enter key to instruct the interpreter to execute the code. Initially you may think of the
interactive interpreter as a powerful calculator. The example program below calculates a salary based on a given hourly
wage, the number of hours worked per week, and the number of weeks per year. The speci±cs of the code are described
elsewhere in the chapter.
PARTICIPATION
ACTIVITY
1.2.1: The Python interpreter.
PARTICIPATION
ACTIVITY
1.2.2: Match the Python terms with their de±nitions.
If unable to drag and drop, refresh the page.
A program that executes computer
code.
The text that represents a computer
program.
Informs the programmer that the
interpreter is ready to accept
commands.
A row of text.
Executing a Python program
The Python interactive interpreter is useful for simple operations or programs consisting of only a few lines. However,
entering code line-by-line into the interpreter quickly becomes unwieldy for any program spanning more than a few lines.
Instead, a programmer can write Python code in a ±le, and then provide that ±le to the interpreter. The interpreter begins
by executing the ±rst line of code at the top of the ±le, and continues until the end is reached.
A statement
is a program instruction. A program mostly consists of a series of statements, and each statement
usually appears on its own line.
Expressions
are code that return a value when evaluated; for example, the code wage * hours * weeks
is an
expression that computes a number. The symbol *
is used for multiplication. The names wage, hours, weeks, and
salary are variables
, which are named references to values stored by the interpreter.
A new variable is created by performing an assignment
using the = symbol, such as
salary = wage * hours * weeks
, which creates a new variable called salary.
The print()
function displays variables or expression values.
'#' characters denote comments
, which are optional but can be used to explain portions of code to a human reader.
Many code editors color certain words, as in the below program, to assist a human reader in understanding various
words' roles.
PARTICIPATION
ACTIVITY
1.2.3: Executing a simple Python program.
Python interpreter
Name
Value
>>>
wage = 20
wage
20
>>>
hours = 40
>>>
weeks = 50
weeks
50
|
>>>
salary = wage * hours * weeks
>>>
print(salary)
40000
>>>
hours = 35
hours
35
>>>
salary = wage * hours * weeks
35000
salary
>>>
print(salary)
35000
>>>
1. After each press of the enter key, the python interpreter executes the line of code.
2. The python interpreter can be used as a calculator and can perform a variety of calculations.
3. Users can change values and execute calculations again.
Captions
Feedback?
Line
Prompt
Interpreter
Code
Reset
Feedback?
Start
2x speed
Start
2x speed
Activity summary for assignment: 1-3 zyBooks Participation Activities
98 %
98 % submitted to desire2learn
PARTICIPATION
ACTIVITY
1.2.4: Python basics.
1)
What is the purpose of variables?
Store values for later use.
Instruct the processor to execute
an action.
Automatically color text in the
editor.
2)
The code 20 * 40 is an expression.
True
False
3)
How are most Python programs
developed?
Writing code in the interactive
interpreter.
Writing code in ±les.
4)
Comments are required in a program.
True
False
zyDE 1.2.1: A ±rst program.
The below program simulates a race between two cars, displaying the position of each car at
the end of the race. Make sure the output box below the code is visible, then click "run."
The car1_top_speed and car1_acceleration variables control the maximum velocity and
acceleration of car 1. Modify these variables, and run the program again. Can you make the
second car win?
You do not need to understand how the code works right now. Instead, just modify the speed
and acceleration variables and observe how the output changes.
How was this
section?
|
wage = 20
hours = 40
weeks = 50
salary = wage * hours * weeks
print
(
'Salary is:'
, salary
)
hours = 35
salary = wage * hours * weeks
print
(
'New salary is:'
, salary
)
file.py
Python interpreter
>>>
Name
Value
wage
20
weeks
50
salary
40000
Salary is: hours
35
35000
35000
New salary is:
1. The python interpreter reads a ±le line by line. Variables wage, hours, and weeks are named
references that refer to values stored by the interpreter.
2. 20 * 40 * 50 is computed, and then assigned to the variable salary.
3. The print statement prints 'Salary is:' to the screen and displays the value of the variable
salary.
4. Values can be overwritten if the same variable name is used.
Captions
Feedback?
Feedback?
Load default template...
# Welcome to the Python 500 race! Click the run button to begin.
# Configurable values.
# Try changing car speeds, accelerations, and the simulation speed.
car1_top_speed = 60
car2_top_speed = 50
car1_acceleration = 11
car2_acceleration = 10
car1 = [
' ______\n'
,
' |__1_|_\\\n'
,
' O----O\n'
]
car2 = [
' ___\n'
,
' /__2_\\__\n'
,
' O----O\n'
]
Run
Feedback?
Provide section feedback
Completion details
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
Computer Science
GIS Cartography Question: Name a couple of ways you could lessen the number of colors used in a class-type map.
arrow_forward
JAVA INTRO
The answer last time was incorrect It did not use text files!!!!.
Create a program that generates a report that displays a list of students, classes they are enrolled in and the professor who teaches the class.
There are 3 files that provide the input data:
1. FinalRoster.txt
List of students and professors ( The first value of each row indicates if it is a student or professor; S means a student , P means a professor)
Student and Professor have different data
Student row: "S",Student Name, StudentID
Professor row: "P", Professor Name, Professor ID, Highest Education
2. FinalClassList.txt
List of classes and professor who teach them
Each row contains the following information: ClassID, ClassName, ID of Professor who teach that class
The professor ID in this file matches the Professor ID in FinalRoster.txt.
3. FinalStudentClassList.txt
List of classes the students are enrolled in. (StudentID, ClassID)
Student ID matches Student ID in FinalRoster.txt and ClassID…
arrow_forward
Instructions
A common problem in textual analysis is to determine the frequency and location of words in a document. The information is stored in a concordance, which lists the distinct words in alphabetical order and makes references to each line on which the word is used. For instance, consider the quotation:
Peter Piper picked a peck of pickled peppers. A peck of pickled
peppers Peter Piper picked. If Peter Piper picked a peck of
pickled peppers, where is the peck that Peter Piper picked?
The word “piper” occurs 4 times in the text and appears on lines 1, 2, and 3. The word “pickled” occurs 3 times and appears on lines 1 and 2.
For the text above, the output of the concordance is:
Write a c++ program to create a concordance for a text file. Since during the process of building the concordance, it is frequently necessary to look up the word in the current words in the concordance, update concordance entries, as well as insert new words into the concordance, a binary…
arrow_forward
Instructions
A common problem in textual analysis is to determine the frequency and location of words in a document. The information is stored in a concordance, which lists the distinct words in alphabetical order and makes references to each line on which the word is used. For instance, consider the quotation:
Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, where is the peck that Peter Piper picked?
The word "piper" occurs 4 times in the text and appears on lines 1, 2, and 3. The word "pickled" occurs 3 times and appears on lines 1 and 2.
For the text above, the output of the concordance is:
Word Frequency Occurs on lines:------------------------------------------------------------------a 3 1, 2if 1 2is 1…
arrow_forward
Computer Science
IN PYTHON(visual studio code) program a simple flag that consists of at least two shapes while only using rectangles and circles. Give it a flagpole by drawing a long skinny rectangle next to it. Wave the flag by animating it up and down. (make the Swedish and UK flag)
import pgzero
arrow_forward
Java assignment
Create a java program that allows a user to input customer records (ID number, first name, last name,
and balance owed) and save each record to a file.
arrow_forward
C Programming Language (Code With C Programming Language)
Problem Title : Visible Trees
There is a legend about a magical park with N × N trees. The trees are positioned in a square grid with N rows (numbered from 1 to N from north to south) and N columns (numbered from 1 to N from west to east). The height (in metres) of each tree is an integer between 1 and N × N, inclusive. Magically, the height of all trees is unique.
Bunga is standing on the northmost point of the park and wants to count the number of visible trees for each Column. Similarly, Lestari is standing on the westmost point of the park and wants to count the number of visible trees for each Row. A tree X is visible if all other trees in front of the tree X are shorter than the tree X.
For example, let N = 3 and the height (in metres) of the trees are as follows6 1 87 5 32 9 4
On the first column, Bunga can see two trees, as the tree on the third row is obstructed by the other trees.
On the second column, Bunga can see…
arrow_forward
Constraints:
Use Python
Don't use global variables
Don't use external libraries (PIL and os are allowed)
Start the program with a main function (def main():)
Content:
Ask the user to input a .jpeg/.jpg image. Once a jpeg file is uploaded, create a function with the argument img_info and return a tuple with the image's dimensions in pixels (w, h) and the image data in a form of a list of tuples with RGB values.
Print out the values/data collected.
arrow_forward
Transcribed Image Text
JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2
arrow_forward
An 8-puzzle game consists of 8 sliding tiles, numbered by digits from 1 to 8 and arranged in a 3x3 array of nine cells. A configuration in the puzzle refers to some specific arrangement of the tiles in the array, where each digit is arranged into a different cell. One of the cell is empty (represented by a "*") and any adjacent tile can be moved into the empty cell. An example below
c | 1 | 2 | 3 b | 4 | * | 5 a | 6 | 7 | 8------------------ Y/X a b c
We use a 3-tuple (number, X, Y) to represent the position of a digit, where number is the actual digit, and (X,Y) is the coordinate value of the digit in the current configuration (e.g., in the configuration above, we have (5,c,b), meaning the digit 5 is at the position of (c,b)).Hence the configuration in the example can be represented as:[(1,a,c), (2,b,c), (3,c,c), (4,a,b), (5,c,b), (6,a,a), (7,b,a), (8,c,a)].Any move of an adjacent tile into the empty cell moves the current configuration into the one adjacent to it.…
arrow_forward
An array is a sequence of data items that are of the same type, that can be indexed, and that are stored contiguously. Typically,an array is called a data structure used to represent a large number of homogeneous values. The elements of an array are accessedby the use of subscripts. Subscripts start from zero and runs until less than the size of the array. Arrays of all types are possible,including multi-dimensional arrays. Strings are just arrays of characters terminated by a special character called the null character.A typical array declaration allocates memory starting from a base address. The array name is in effect a constant pointer to thismemory address.a) Write a complete C program that demonstrates the usage of character strings. The program should declare an emptycharacter array of specific size, and then ask user to enter a string to be stored in the array using a scanf function. Theprogram should finally display the string entered to the screen for checking if the…
arrow_forward
Algorithm design with sorting. Each of n users spends some time on a social media site. For each i = 1, . . . , n, user i enters the site at time ai and leaves at time bi ≥ ai. You are interested in the question: how many distinct pairs of users are ever on the site at the same time? (Here, the pair (i, j) is the same as the pair (j, i)).Example: Suppose there are 5 users with the following entering and leaving times:
Then, the number of distinct pairs of users who are on the site at the same time is five: these pairs are (1, 2), (1, 3), (2, 3), (4, 6), (5, 6). (Drawing the intervals on a number line may make this easier to see).(a) Given input (a1 , b1),(a2 , b2), . . . ,(an, bn) as above in no particular order (i.e., not sorted in any way), describe a straightforward algorithm that takes Θ(n2)-time to compute the number of pairs of users who are ever on the site at the same time, and explain why it takes Θ(n2)-time. [We are expecting pseudocode and a brief justification for its…
arrow_forward
Subject: Web Development
Language: JavaScript (only JavaScript)
I will report if you do it in any other Language
Question:
Declare a variable and assign value, define a function that returns text, return number of characters in a string, function to return characters of a string in Upper/lowercase, function to replace character in string, function to add amounts with surcharge, function to get first element of an array, etc.
arrow_forward
Q2) An image is a matrix of pixels. You must have seen two types of images: color andgrayscale. A color image pixel has three colors: Red, Green, and Blue, but a grayscale imagepixel has only one color: Gray. Regardless of the image type, a color always has an 8-bitinteger value (0-255) associated with it. You need to implement a program that can input,create, update and display the images (matrices). It should be able to compute their negatives(matrices) as well. NOTE: You need to generalize the computation of negatives, for we onlyneed to subtract the color values from 255, regardless of the image type.
arrow_forward
C++ only. Do not copy. Correct code will upvoted else downvote.
Monocarp is playing a PC game. Presently he needs to finish the principal level of this game.
A level is a rectangular framework of 2 lines and n sections. Monocarp controls a character, what begins in cell (1,1) — at the convergence of the 1-st line and the 1-st segment.
Monocarp's character can move starting with one cell then onto the next in one stage if the cells are nearby by side or potentially corner. Officially, it is feasible to move from cell (x1,y1) to cell (x2,y2) in one stage if |x1−x2|≤1 and |y1−y2|≤1. Clearly, it is denied to go external the matrix.
There are traps in certain cells. In case Monocarp's character winds up in such a cell, he bites the dust, and the game closures.
To finish a level, Monocarp's character should arrive at cell (2,n) — at the crossing point of line 2 and section n.
Assist Monocarp with deciding whether it is feasible to finish the level.
Input
The principal…
arrow_forward
Timesheet data is easy to represent in a file, where it can be used to generate a report and help the worker get paid! Given an example set of data where each row represents a day of the week and each entry on the row represents a block of time worked, like this:
0h1.5h 3.25h3.0h 6.0h 1.0h5.5h 2.25h 0.75h2.25h 3.0h 3.0h5.75h 2.25h0h
A report could be produced by a program like this:
---------------------------------------0.00h | 0.00h5.25h | 1.50h 3.25h 0.50h10.00h | 3.00h 6.00h 1.00h8.50h | 5.50h 2.25h 0.75h8.25h | 2.25h 3.00h 3.00h8.00h | 5.75h 2.25h0.00h | 0.00h---------------------------------------Weekly Total: 40.00h
Notice how in the output file all the numbers are nicely formatted as right-aligned. Hint: you will probably need to use splitting, string slicing, converting data types, and string formatting.
For your assignment, create a program that uses a data file that you have created, parses the data in that file to create a calculation per row and a running total, then…
arrow_forward
Transcribed Image Text
Question 18 D The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially facing toward the top of the grid. The following code segment moves the robot around the grid. Assume that n is a positive integer.
arrow_forward
Machine Problem: JAVA LANGUAGE
Write a Java program that will display the given menu:
NOTE: adding a string must accept a word/phrase/sentence
Important factor in phrase or sentence input: e.g (HELP me) 3. display uppercase -> HELP only
4. display lower case -> me
Menu
1. Add a string
2. Display list of strings
3. Display list of uppercase words
4. Display list of lowercase words
5. Delete an uppercase word
6. Delete a lowercase word
7. End program
When 1 is chosen, ask the user to enter a string and add it to a list using a linked list
When 2 is chosen, display the list of strings.
When 3 is chosen, display all uppercase words found in the list of strings in ascending order. (create a linked list containing all uppercase words)
When 4 is chosen, display all lowercase words found in the list of strings in ascending order. (create a linked list containing all lowercase words)
When 5 is chosen, display the list of uppercase words then ask the user…
arrow_forward
C++ Language
Write a program that prints a custom conversion table from Celsius temperatures to Fahrenheit and Newton (Links to an external site.) temperatures. The formula for the conversion from Celsius to Fahrenheit is :
F=9/5*C+32
F is the Fahrenheit temperature, and C is the Celsius temperature.
The formula for the conversion from Celsius to Newton is
C = 100/33*N
N is the Newton Temperature and C is the Celsius temperature
Your program should prompt the user for a lower value and upper value for a range of temperatures in Celsius. It should then prompt the user for the amount they want to increment by. Then use a loop to output to a file named conversion_table.txt a table of the Celsius temperatures and their Fahrenheit and Newton equivalents within the range of values using the increment given by the user. Make sure to format your output to 2 decimal places.
INPUT VALIDATION: Ensure the second number is greater than the first number, and make sure the increment is greater…
arrow_forward
Instructions:
I need Python help.
The problem I am trying to figure out so that when we work a similar problem in class I can do my assignment. Tonights assignment is a participation thing, Friday I need to do a similar assignment in class for a grade.
Write a program that reads movie data from a CSV (comma separated values) file and output the data in a formatted table. The program first reads the name of the CSV file from the user. The program then reads the CSV file and outputs the contents according to the following requirements:
Each row contains the title, rating, and all showtimes of a unique movie.
A space is placed before and after each vertical separator ('|') in each row.
Column 1 displays the movie titles and is left justified with a minimum of 44 characters.
If the movie title has more than 44…
arrow_forward
Please add an gif image/plot an gif to this code. This is a brownian motion python code
here it is code
import numpy as np
import matplotlib.pyplot as plt
def brownian_motion(L, N):
# initialize position in the center of the grid
x = L // 2
y = L // 2
# initialize the grid
grid = np.zeros((L, L), dtype=np.int32)
# loop over the number of steps
for i in range(N):
# choose a random direction
direction = np.random.choice(['up', 'down', 'left', 'right'])
# move one step in that direction
if direction == 'up':
" y += 1"
elif direction == 'down':
"y -= 1"
elif direction == 'left':
"x -= 1"
elif direction == 'right':
"x += 1"
# make sure the particle is still on the grid
if x < 0 or x >= L or y < 0 or y >= L:
"continue"
# update the grid
grid[y, x] = 1
return grid
if __name__ == '__main__':
# set the size of the grid
L…
arrow_forward
Please help me with these questions. I dont know how to draw these flowchart (Practice Worksheets)
Programming language (HTML, CSS, JavaScript)
Just draw the flowchat and write the post and preconditions for both Ex 14 and Ex 15
Ex 14) Devise an algorithm to input an integer greater than 1 as n, and output the first n values of the Fibonacci sequence. In Fibonacci sequence, the first two values are 0 and 1 and other values are sum of the two values preceding it. For instance, if the input is 4, the program should print 0, 1, 1, 2. As another example, if the input is 9, the program should output 0, 1, 1, 2, 3, 5, 8, 13, 21.
Ex 15) Devise an algorithm to input a positive integer, n, – and by using ‘*’ characters – output the figure below that has n rows, with 3 ‘*’ characters in the top row and 3*n characters in the last row. For instance, if input is 5, the figure on the left (and if the input is 12, the figure on the right) should be generated by the program.
arrow_forward
All the information needed in the question. Use Java programming language.
There is a CD available for purchase that contains .jpeg and .gif images of music that is in the public domain. The CD includes a file consisting of lines containing the names, then composers of that title, one per line. The name of the piece is first, then zero or more spaces then a dash (-) character, then one or more spaces, then the composer's name. The composer name may be only the last name, an initial and one name, two names (first and last), or three names (first, middle, and last). There are a few tunes with "no author listed" as author. In the subsequent processing, "no author listed" should not be rearranged. Here is a very abbreviated list of the titles and authors.
1. Adagio "MoonLight" Sonata - Ludwig Van Beethoven2. An Alexis - F.H. Hummel and J.N. Hummel3. A La Bien Aimee - Ben Schutt4. At Sunset - E. MacDowell5. Angelus - J. Massenet6. Anitra's Dance - Edward Grieg7. Ase's Death - Edward…
arrow_forward
JAVA CODE THANK YOU
2. Binary Search
by CodeChum Admin
Searching is one very important Computer Science task. When you have a list, searching is natural. You would want to search for an item in the list. If the list is not sorted, there is no way to it but do a linear search - check each element until the item is found or until there are no elements left to inspect.
But when the list is sorted, searching becomes way faster! Think of the dictionary; the actual printed dictionary. The words there are sorted from A-Z. And searching for what soliluquy means you should not start from A and turning the pages one by one until you reach the entries for the letter S.
What do you usually do? You open the dictionary right smack in the middle and see if you are in the letter S. If you are short and are brought to a letter before S, you try to estimate and open a page to the right of where you are currently. If you went beyond S, you try to open a page before the page you are currently…
arrow_forward
Problem DNA: Subsequence markingA common task in dealing with DNA sequences is searching for particular substrings within longer DNA sequences.
Write a function mark_dna that takes as parameters a DNA sequence to search, and a shorter target sequence to find within the longer sequence. Have this function return a new altered sequence that is the original sequence with all non-overlapping occurrences of the target surrounded with the characters >> and <<.
Hints:
● String slicing is useful for looking at multiple characters at once.
● Remember that you cannot modify the original string directly, you’ll need to build a copy.
Start with an empty string and concatenate onto it as you loop.
Constraints:
● Don't use the built-in replace string method. All other string methods are permitted.
>>> mark_dna('atgcgctagcatg', 'gcg') 'at>>gcg<<ctagcatg' >>> mark_dna('atgcgctagcatg', 'gc')…
arrow_forward
python language. Instructions are given within the quotations.
def get_word_score(word, value_dict):
"""
Given a word, and a dictionary matching each letter to an int score,
calculates the word's score (adding up each letter's score)
and return the score.
"""
return 0
arrow_forward
Python exercice.
consider the atttached file for further details.
Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in the figures below.
Original
Sepia
Original Image & Sepia Image
Write and test a function named sepia that converts a color image to sepia. This function should first call grayscale to convert the color image to grayscale. A code segment for transforming the grayscale values to achieve a sepia effect follows.Note that the value for green does not change.
(red, green, blue) = image.getPixel(x, y)if red < 63: red = int(red * 1.1) blue = int(blue * 0.9)elif red < 192: red = int(red * 1.15) blue = int(blue * 0.85)else: red = min(int(red * 1.08), 255) blue = int(blue * 0.93)
images.py
To instantiate an image from a file, enter
image = Image(aGifFileName)
To…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Related Questions
- Computer Science GIS Cartography Question: Name a couple of ways you could lessen the number of colors used in a class-type map.arrow_forwardJAVA INTRO The answer last time was incorrect It did not use text files!!!!. Create a program that generates a report that displays a list of students, classes they are enrolled in and the professor who teaches the class. There are 3 files that provide the input data: 1. FinalRoster.txt List of students and professors ( The first value of each row indicates if it is a student or professor; S means a student , P means a professor) Student and Professor have different data Student row: "S",Student Name, StudentID Professor row: "P", Professor Name, Professor ID, Highest Education 2. FinalClassList.txt List of classes and professor who teach them Each row contains the following information: ClassID, ClassName, ID of Professor who teach that class The professor ID in this file matches the Professor ID in FinalRoster.txt. 3. FinalStudentClassList.txt List of classes the students are enrolled in. (StudentID, ClassID) Student ID matches Student ID in FinalRoster.txt and ClassID…arrow_forwardInstructions A common problem in textual analysis is to determine the frequency and location of words in a document. The information is stored in a concordance, which lists the distinct words in alphabetical order and makes references to each line on which the word is used. For instance, consider the quotation: Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, where is the peck that Peter Piper picked? The word “piper” occurs 4 times in the text and appears on lines 1, 2, and 3. The word “pickled” occurs 3 times and appears on lines 1 and 2. For the text above, the output of the concordance is: Write a c++ program to create a concordance for a text file. Since during the process of building the concordance, it is frequently necessary to look up the word in the current words in the concordance, update concordance entries, as well as insert new words into the concordance, a binary…arrow_forward
- Instructions A common problem in textual analysis is to determine the frequency and location of words in a document. The information is stored in a concordance, which lists the distinct words in alphabetical order and makes references to each line on which the word is used. For instance, consider the quotation: Peter Piper picked a peck of pickled peppers. A peck of pickled peppers Peter Piper picked. If Peter Piper picked a peck of pickled peppers, where is the peck that Peter Piper picked? The word "piper" occurs 4 times in the text and appears on lines 1, 2, and 3. The word "pickled" occurs 3 times and appears on lines 1 and 2. For the text above, the output of the concordance is: Word Frequency Occurs on lines:------------------------------------------------------------------a 3 1, 2if 1 2is 1…arrow_forwardComputer Science IN PYTHON(visual studio code) program a simple flag that consists of at least two shapes while only using rectangles and circles. Give it a flagpole by drawing a long skinny rectangle next to it. Wave the flag by animating it up and down. (make the Swedish and UK flag) import pgzeroarrow_forwardJava assignment Create a java program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file.arrow_forward
- C Programming Language (Code With C Programming Language) Problem Title : Visible Trees There is a legend about a magical park with N × N trees. The trees are positioned in a square grid with N rows (numbered from 1 to N from north to south) and N columns (numbered from 1 to N from west to east). The height (in metres) of each tree is an integer between 1 and N × N, inclusive. Magically, the height of all trees is unique. Bunga is standing on the northmost point of the park and wants to count the number of visible trees for each Column. Similarly, Lestari is standing on the westmost point of the park and wants to count the number of visible trees for each Row. A tree X is visible if all other trees in front of the tree X are shorter than the tree X. For example, let N = 3 and the height (in metres) of the trees are as follows6 1 87 5 32 9 4 On the first column, Bunga can see two trees, as the tree on the third row is obstructed by the other trees. On the second column, Bunga can see…arrow_forwardConstraints: Use Python Don't use global variables Don't use external libraries (PIL and os are allowed) Start the program with a main function (def main():) Content: Ask the user to input a .jpeg/.jpg image. Once a jpeg file is uploaded, create a function with the argument img_info and return a tuple with the image's dimensions in pixels (w, h) and the image data in a form of a list of tuples with RGB values. Print out the values/data collected.arrow_forwardTranscribed Image Text JAVA Programming Problem: In the game of "Assassin's Creed", you control a ship with a cannon which is attacking a large enemy Assassin's Creed, armed with many guns. Your goal is to destroy as many of the guns as possible. The battle field is a 2D Cartesian grid, where your cannon is located at the origin. The enemy Assassin's Creed is a horizontal line segment located from the coordinates (X1, Y) to (X2, Y). There are exactly (X2 - X1 + 1) guns on the ship, located at the integer points (X1, Y), (X1+1, Y), ..., (X2, Y). However, the problem is, you cannot always fire at a gun. There are supernatural rocks located at all points of the battlefield whose X and Y coordinates are both integers. In order to fire successfully at an enemy's gun, the line connecting your cannon and that gun must not go through any rocks. Develop a JAVA code to output the number of the enemy battleship's guns that your cannon can destroy. Test Case Result 1 2 2 -2arrow_forward
- An 8-puzzle game consists of 8 sliding tiles, numbered by digits from 1 to 8 and arranged in a 3x3 array of nine cells. A configuration in the puzzle refers to some specific arrangement of the tiles in the array, where each digit is arranged into a different cell. One of the cell is empty (represented by a "*") and any adjacent tile can be moved into the empty cell. An example below c | 1 | 2 | 3 b | 4 | * | 5 a | 6 | 7 | 8------------------ Y/X a b c We use a 3-tuple (number, X, Y) to represent the position of a digit, where number is the actual digit, and (X,Y) is the coordinate value of the digit in the current configuration (e.g., in the configuration above, we have (5,c,b), meaning the digit 5 is at the position of (c,b)).Hence the configuration in the example can be represented as:[(1,a,c), (2,b,c), (3,c,c), (4,a,b), (5,c,b), (6,a,a), (7,b,a), (8,c,a)].Any move of an adjacent tile into the empty cell moves the current configuration into the one adjacent to it.…arrow_forwardAn array is a sequence of data items that are of the same type, that can be indexed, and that are stored contiguously. Typically,an array is called a data structure used to represent a large number of homogeneous values. The elements of an array are accessedby the use of subscripts. Subscripts start from zero and runs until less than the size of the array. Arrays of all types are possible,including multi-dimensional arrays. Strings are just arrays of characters terminated by a special character called the null character.A typical array declaration allocates memory starting from a base address. The array name is in effect a constant pointer to thismemory address.a) Write a complete C program that demonstrates the usage of character strings. The program should declare an emptycharacter array of specific size, and then ask user to enter a string to be stored in the array using a scanf function. Theprogram should finally display the string entered to the screen for checking if the…arrow_forwardAlgorithm design with sorting. Each of n users spends some time on a social media site. For each i = 1, . . . , n, user i enters the site at time ai and leaves at time bi ≥ ai. You are interested in the question: how many distinct pairs of users are ever on the site at the same time? (Here, the pair (i, j) is the same as the pair (j, i)).Example: Suppose there are 5 users with the following entering and leaving times: Then, the number of distinct pairs of users who are on the site at the same time is five: these pairs are (1, 2), (1, 3), (2, 3), (4, 6), (5, 6). (Drawing the intervals on a number line may make this easier to see).(a) Given input (a1 , b1),(a2 , b2), . . . ,(an, bn) as above in no particular order (i.e., not sorted in any way), describe a straightforward algorithm that takes Θ(n2)-time to compute the number of pairs of users who are ever on the site at the same time, and explain why it takes Θ(n2)-time. [We are expecting pseudocode and a brief justification for its…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Systems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning