Escolar Documentos
Profissional Documentos
Cultura Documentos
------------------------------------------
CIS 244 Have you ever experience some kind of a
virus
------------------------------------------
CIS 3443 Chapter 4 Decisions and Conditions
------------------------------------------
CMIS 141 Homework 2
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Homework 2
Before attempting this project, be sure you have completed all of
the reading assignments, hands-on
labs, discussions, and assignments to date.
Design a Java class named Polygon that contains: A private int
data field named numSides that defines the number of sides of the
polygon. The default value should be 4.
A private double data field named sideLength that defines the
length of each side. The
default value should be 5.0.
A private double data field named xCoord that defines the x-
coordinate of the center of
the polygon. The default value should be 0.0.
A private double data field named yCoord that defines the y-
coordinate of the center of
the polygon. The default value should be 0.0.
A private double data field named apothem that defines the
apothem of the polygon.
The default value should 5.0.
A private double data filed named perimeter that defines the
perimeter of the polygon.
The default value should 20.0.
A no argument constructor that creates a Polygon using the
default number of sides,
default side length, default x- and y-coordinates, and the default
apothem.
A constructor that creates a Polygon using a specified number of
sides, side length, xand y-coordinates and the apothem
Getter and setter methods for all data fields
A getArea() method that returns a double value representing the
area of the polygon.
(Note the area of a regular Polgon can be calculated from *
Apothem*Perimeter)
A toString() method that displays the number of sides, side length,
x-coordinate, ycoordinate and apothem values in String format
Be sure your code compiles. You should use the command prompt
and not a GUI for data entry and
display.
Write a Java test program, named TestPolygon, to create 5
different polygons representing the 5 test
cases you just created. When creating the five polygons, create
one using the no argument constructor.
For the remaining four, feel free to use any number of sides, side
length and x-, and y-coordinates and
apothem that are not equal to the default values and not equal to
each other. For each of the five
polygons, call all of the methods and display the results. For
example for a Polygon with 3 sides, side
length of 2.0 and x-coordinate and y-coordinates of 1.0, and
apothem of 1.0 the following test data may
result:
***Output***
toString(): (numsides=3, sideLength=2.0, xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3
getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0 1 getArea(): 3.0 Document your test cases in
the form of table with columns indicating the input values,
expected
output, actual output and if the test case passed or failed. This
table should contain 4 columns with
appropriate labels and a row for each test case. An example
template is shown below. Note that the
actual output should be the actual results you receive when
running your program and applying the
input for the test record.
Keep in mind, for five Polygons, you will have five different
output results. Also, note there is no
requirement to actually draw a Polygon.
Example test cases:
Input
Constructor:
numsides=3
sideLength=2.0
xcoord=1.0
ycoord=1.0
apothem=1.0 Expected Output
** Output ** Actual Output
** Output ** toString(): (numsides=3,
sideLength=2.0,
xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3
getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0
getArea(): 3.0 toString(): (numsides=3,
sideLength=2.0,
xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0
getArea(): 3.0 Pass?
Yes Test case 2 here
Test case 3 here
Test case 4 here
Test case 5 here The google recommended Java style guide,
provided as link in the week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. 2 Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
named appropriately for your applications. The word (or PDF)
document should include screen captures
showing the successful compiling and running of each of the test
cases. Each screen capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Homework 2 assignment area no later
than the due date listed in your LEO
classroom. You should include your name and HW2 in your word
(or PDF) file submitted (e.g.
firstnamelastnamehw2.docx or firstnamelastnamehw2.pdf)
Grading Rubric:
The following grading rubric will be used to determine your
grade:
Attribute
Polygon Class Meets
10 points Does not meet
0 points Private int data field named
numSides that defines the
number of sides of the polygon.
The default value should be 4. Private int data field named
numSides was not included. Private double data field named
sideLength that defines the
length of each side. The default
value should be 5.0.
Private double data field named
xCoord that defines the xcoordinate of the center of the
polygon. The default value
should be 0.0.
Private double data field named
yCoord that defines the ycoordinate of the center of the
polygon. The default value
should be 0.0.
Private double data field named
apothem that defines the
apothem of the polygon. The
default value should 5.0. Private double data field named
sideLength was not included
Private double data field named
xCoord was not included
Private double data field named
yCoord was not included
Private double data field named
apothem was not included.
Private double data filed named
perimeter was not included
No argument constructor that
creates a Polygon was not
included
Constructor that creates a
Polygon using a specified
number of sides, side length, xand y-coordinates and the
apothem was not included Private double data filed named
perimeter that defines the
3 perimeter of the polygon. The
default value should 20.0. Getter and setter methods for
all data fields were not included No argument constructor that
creates a Polygon using the
default number of sides, default
side length, default x- and ycoordinates, and the default
apothem. getArea() method was not
included Constructor that creates a
Polygon using a specified
number of sides, side length, xand y-coordinates and the
apothem toString() method was not
included
Command Line was not used for
running application Getter and setter methods for
all data fields
getArea() method that returns a
double value representing the
area of the polygon. (Note the
area of a regular Polgon can be
calculated from *
Apothem*Perimeter)
toString() method that displays
the number of sides, side
length, x-coordinate, ycoordinate and apothem values
in String format Test Polygon Class Command line was used for
running the application.
5 points 0 points TestPolygon used to create 5
different polygons representing
the 5 test cases you just
created. TestPolygon was not used to
create 5 different polygons
representing the 5 test cases
you just created. One test cases used the no
argument constructor. One test cases was not used
with the no argument
constructor. An additional 4 test cases with
varying input values. 4 Test Cases For each of the five polygons,
all of the methods were called
and resulted displayed. An additional 4 test cases with
varying input values were not
used. Command Line was used for
output. For each of the five polygons,
none of the methods were
called 5 points
A minimum of 5 test cases was
used in the form of table with
columns indicating the input
values, expected output, actual
output and if the test case
passed or failed. The table
should contains 4 columns with
appropriate labels and a row for
each test case. Documentation and Style guide Test cases were
included in the
supporting word or PDF
documentation.
5 points
Screen captures were provided
and labeled for compiling your
code, and running each of your
5 test cases. Command Line was not used for
output.
0 points
No test cases were provided. 0 points
No documentation included
Java style guide was not used to
prepare the Java code. Header comments include
filename, author, date and brief
purpose of the program.
In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied.
Class names are written in
UpperCamelCase. 5 Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style. 6
------------------------------------------
CMIS 141 Homework 3
Homework 3
Before attempting this project, be sure you have completed all of
the reading assignments, hands-on
labs, discussions, and assignments to date.
Create a Java class named HeadPhone to represent a headphone
set. The class contains: Three constants named LOW, MEDIUM
and HIGH with values of 1, 2 and 3 to denote the
headphone volume.
A private int data field named volume that specifies the volume of
the headphone. The
default volume is MEDIUM.
A private boolean data field named pluggedIn that specifies if the
headphone is plugged
in. The default value is false.
A private String data field named manufacturer that specifies the
name of the
manufacturer of the headphones.
A private Color data field named headPhoneColor that specifies
the color of the
headphones.
A private String data field named headPhoneModel that specifies
the Model of the
headphones.
getter and setter methods for all data fields.
A no argument constructor that creates a default headphone.
A method named toString() that returns a string describing the
current field values of
the headphones.
A method named changeVolume(value) that changes the volume
of the headphone to
the value passed into the method Create a TestHeadPhone class
that constructs at least 3 HeadPhone objects. For each of the
objects
constructed, demonstrate the use of each of the methods. Be sure
to use your IDE to accomplish this
assignment.
The google recommended Java style guide, provided as link in the
week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
named appropriately for your applications. The word (or PDF)
document should include screen captures showing the successful
compiling and running of each of the test cases. Each screen
capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Homework 3 assignment area no later
than the due date listed in your LEO
classroom. You should include your name and HW3 in your word
(or PDF) file submitted (e.g.
firstnamelastnamehw3.docx or firstnamelastnamehw3.pdf)
Grading Rubric:
The following grading rubric will be used to determine your
grade:
Attribute
Headphone Class Meets
10 points Does not meet
0 points Three constants named LOW,
MEDIUM and HIGH with values
of 1, 2 and 3 to denote the
headphone volume Three constants named LOW,
MEDIUM and HIGH with values
of 1, 2 and 3 were not included. A private int data field named
volume that specifies the
volume of the headphone. The
default volume is MEDIUM.
A private boolean data field
named pluggedIn that specifies
if the headphone is plugged in.
The default value is false.
A private String data field
named manufacturer that
specifies the name of the
manufacturer of the
headphones. A private int data field named
volume was not included.
A private boolean data field
named pluggedIn was not
included.
A private String data field
named manufacturer was not
included
A private Color data field named
headPhoneColor was not
included. A private String data field
named headPhoneModel wasA private Color data field named not
included
headPhoneColor that specifies
the color of the headphones.
getter and setter methods for
all data fields were not
A private String data field
included.
named headPhoneModel that
specifies the Model of the
A no argument constructor was
headphones.
not included. getter and setter methods for
all data fields. A method named toString()was
not included. A no argument constructor that
creates a default headphone. A method named
changeVolume(value) was not
included. A method named toString() that
returns a string describing the
current field values of the
headphones. An IDE (Netbeans or Eclipse)
was not used for this
assignment. A method named
changeVolume(value) that
changes the volume of the
headphone to the value passed
into the method Test Headphone Class An IDE (Netbeans or
Eclipse)
was used for this assignment.
5 points 0 points TestHeadPhone class was used
to construct at least 3
HeadPhone objects. TestHeadPhone class was not
used to construct at least 3
HeadPhone objects. For each of the objects
constructed, the use of each of
the methods was demonstrated For each of the objects
constructed, the use of each of
the methods was not
demonstrated An IDE (Netbeans or Eclipse)
was used for this assignment. Test Cases 5 points
A minimum of 3 test cases was
used in the form of table with
columns indicating the input
values, expected output, actual
output and if the test case
passed or failed. The table
should contains 4 columns with
appropriate labels and a row for
each test case. An IDE (Netbeans or Eclipse)
was not used for this
assignment.
0 points
No test cases were provided. Documentation and Style guide Test
cases were included in the
supporting word or PDF
documentation.
5 points
Screen captures were provided
and labeled for compiling your
code, and running each of your
5 test cases.
Header comments include
filename, author, date and brief
purpose of the program.
In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied.
Class names are written in
UpperCamelCase.
Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style. 0 points
No documentation included
Java style guide was not used to
prepare the Java code.
------------------------------------------
CMIS 141 Homework 4
------------------------------------------
CMIS 141 Project 4 This programming project
Project 4
This programming project involves writing a program to manage
a student database. The interface to
the program should be a GUI that looks similar to the following:
A combo box should allow the user to select one of the four
database actions shown. The database
should be implemented as a HashMap, with the ID field as the key
and a student record consisting of a
name and major as the value. The operation should be performed
when the user clicks the Process
Request button. If the user attempts to insert a key that is already
in the database an error message
should be displayed using a JOptionPane message dialog box. If
the user attempts to delete, find or
update a record that is not in the database, a message should also
be displayed. After each successful
operation is completed a JOptionPane window should be
displayed confirming the success. In the case
of a successful Find request, a window should pop up containing
the student's ID, name, major and
current GPA. When the user selects the Update request, the
following JOptionPane windows should be
displayed to gather information about a course that has just been
completed: 1 This program must consist of two classes.
1. The first class should define the GUI and handle the database
interactions.
2. The second class named Student, should define the student
record. It must have instance
variables for the student name, major and two variables that are
used to compute the GPA. A
variable that contains the total number of credits completed and a
second variable that contains
the total quality points, which are the numeric value of the grade
received in a course times the
number of credit hours. It should not contain the student ID. The
class should have the following
three methods:
a. A constructor that is used when new student records are
created. It should accept the name
and major as parameters and initialize the fields that are used to
compute the GPA to zero.
b. The second method courseCompleted should accept the course
grade and credit hours and
update the variables used to compute the GPA. It will be called
when an Update request is
made.
c. The third method should override toString and return a labeled
string containing the
student name, major and GPA.
Finally when a student has not yet completed any course, the GPA
should be displayed as 4.0.
The google recommended Java style guide, provided as link in the
week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. In addition the following design
constraints should be followed: Declare all instance variables
private
Avoid the duplication of code
Also any exceptions thrown by nonnumeric inputs should be
properly handled Test cases should be supplied in the form of
table with columns indicating the input values, expected
output, actual output and if the test case passed or failed. This
table should contain 4 columns with
appropriate labels and a row for each test case. Note that the
actual output should be the actual results
you receive when running your program and applying the input
for the test record. Be sure to select
enough different scenarios to completely test the program.
Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
2 named appropriately for your applications. The word (or PDF)
document should include screen captures
showing the successful compiling and running of each of the test
cases. Each screen capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Project 4 assignment area no later than
the due date listed in your LEO
classroom. You should include your name and P4 in your word (or
PDF) file submitted (e.g.
firstnamelastnameP4.docx or firstnamelastnameP4.pdf). Grading
Rubric:
The following grading rubric will be used to determine your
grade:
Attribute GUI Class Meets
40 points Does not meet
0 points Defines the GUI. Does not defines the GUI. Provides a
combo box to allow
the user to select one of the
four database actions including
insert, update, delete and find. Does not provide a combo box
to allow the user to select one
of the four database actions
including insert, update, delete
and find. The database is implemented as
a HashMap, with the ID field as
the key and a student record
consisting of a name and major
as the value.
The operation is performed
when the user clicks the Process
Request button.
If the user attempts to insert a
key that is already in the
database an error message is
displayed using a JOptionPane
message dialog box.
If the user attempts to delete,
find or update a record that is
not in the database, a message
is displayed. The database is not
implemented as a HashMap,
with the ID field as the key and
a student record consisting of a
name and major as the value.
The operation is not performed
when the user clicks the Process
Request button.
If the user attempts to insert a
key that is already in the
database an error message is
not displayed using a
JOptionPane message dialog
box.
If the user attempts to delete,
find or update a record that is 3 After each successful operation
is completed a JOptionPane
window is displayed confirming
the success.
In the case of a successful Find
request, a window pops-up
containing the student's ID,
name, major and current GPA.
When the user selects the
Update request, a JOptionPane
windows is displayed to gather
information about a course that
has just been completed
including the grade and number
of credits. Student class 40 points
Defines the student record.
Contains instance variables for
the student name, major and
two variables that are used to
compute the GPA.
Contains a variable
representing the total number
of credits completed
Contains a variable representing
the total quality points, which
are the numeric value of the
grade received in a course times
the number of credit hours.
The class should not should
contain the student ID. not in the database, a message
is not displayed.
After each successful operation
is completed a JOptionPane
window is not displayed
confirming the success.
In the case of a successful Find
request, a window does not
pop-up containing the student's
ID, name, major and current
GPA.
When the user selects the
Update request, a JOptionPane
window is not be displayed to
gather information about a
course that has just been
completed including the grade
and number of credits.
0 points
Does not define the student
record.
Does not contains instance
variables for the student name,
major and two variables that
are used to compute the GPA.
Does not contain a variable
representing the total number
of credits completed
Does not contain a variable
representing the total quality
points, which are the numeric
value of the grade received in a
course times the number of
credit hours.
The class contains the student
ID. Contains a constructor that is
used when new student records
are created. It should accept the Does not contains a constructor
name and major as parameters that is used when new student
4 and initialize the fields that are
used to compute the GPA to
zero.
Contains a method
courseCompleted that accepts
the course grade and credit
hours and update the variables
used to compute the GPA.
courseComplete is called when
an Update request is made.
Contains an overridden toString
method that returns a labeled
string containing the student
name, major and GPA. Test Cases records are created. It should
accept the name and major as
parameters and initialize the
fields that are used to compute
the GPA to zero.
Does not contains a method
courseCompleted that accepts
the course grade and credit
hours and update the variables
used to compute the GPA.
courseComplete is not called
when an Update request is
made. Calculates and displays a GPA of
4.0 for students who have not
yet completed any course. Does not contains an
overridden toString method
that returns a labeled string
containing the student name,
major and GPA. 10 points Does not calculate or display a
GPA of 4.0 for students who
have not yet completed any
course.
0 points Test cases are supplied in the
form of table with columns
indicating the input values,
expected output, actual output
and if the test case passed or
failed. No test cases were provided. Enough scenarios selected to
completely test the program. Documentation and Style guide Test
cases were included in the
supporting word or PDF
documentation.
10 points
Screen captures were provided
and labeled for compiling your 0 points
No documentation included. 5 code, and running each of your
test cases. Java style guide was not used to
prepare the Java code. Header comments include
filename, author, date and brief
purpose of the program. All instance variables not
declared private. In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied. Duplication of code was not
avoided.
any exceptions thrown by
nonnumeric inputs are not
properly handled Class names are written in
UpperCamelCase.
Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style.
Declare all instance variables
private.
Avoids the duplication of code.
Any exceptions thrown by
nonnumeric inputs are properly
handled. 6
-----------------------------------------------
#Python, cant het this code to work. any help will be great!
deftwoWords(length, firstLetter):
while True:
if len (length) == 4:
return length
break
while True:
return firstLetter
break
twoWords(length, firstLetter)
------------------------------------------
Cs 100 2014_midterm2: Question 11 to 13
Question 1
for i in range(-3, 0):
print(i, end=' ')
a.
b.
c.
d.
e. no output
-3 -2 -1 0
0 -1 -2 -3
-3 -2 -1
none of the above Question 2
mess = 'hodge podge'
count = 0
idx = 0
while idx < len(mess):
if mess.count(mess[idx]) > 1:
count += mess.count(mess[idx])
else:
count += 1
idx += 1
print(count)
a.
b.
c.
d.
e. 8
9
11
18
none of the above Question 3
s = 'sliceMagic'
print(s[:] + s['M':] + s[:'M'])
a.
b.
c.
d.
e. TypeError: slice indices must be integers
sliceMagicMagicslice
sliceMagicMagicsliceM
Magicslice
none of the above Question 4
parting = 'too-da-loo'
aList = ['oo', '-', 'oo']
inCount = 0
for i in range(len(parting)-1):
if parting[i] + parting[i+1] in aList:
inCount += 1
print(inCount)
a.
b.
c.
d.
e. 1
2
3
4
none of the above Question 5
xChars = ['Mystique', 'Wolverine']
vowels = 'aeiou'
for vowel in vowels:
for char in xChars:
if vowel not in char:
continue
print(char[0], end='')
a.
b.
c.
d.
e. the empty string
MW
MWMMW
MWMWWM
none of the above Question 6
pandemics = [['HIV', 'Ebola', 'SARS'], ['polio', 'smallpox'], 'flu']
print(pandemics[2:])
a.
b.
c.
d.
e. SARS
['SARS']
['smallpox'] flu
none of the above Question 7
def returnDictVal(d, aKey):
if aKey in d:
return d[aKey]
else:
return None
chars = {'Alice':['rabbit', 'caterpiller'], 'superman':'Clark'}
wonderWomanChars = {'wonder woman':['Lynda Carter', 'Gal
Gadot']}
print(returnDictVal(chars, 'wonder woman'))
a.
b.
c.
d.
e. the empty string
None
NameError: name 'returnDictVal' is not defined
['Lynda Carter', 'Gal Gadot']
none of the above Question 8
bools = [True or False, True, True and False, True and not False]
trues = 0
for bool in bools:
if bool == True:
trues += 1
continue
break
print(trues)
a.
b.
c.
d.
e. TypeError: bool takes 1 positional argument but 2 were given
0
2
3
none of the above Question 9
anonymous = 'hollywood is the opium of the people'
def nonSubStr(t, subStr):
rtn = aList = t.split()
for s in aList:
if subStr not in s:
rtn.append(s)
return rtn
print(nonSubStr(anonymous, 'o'))
a.
b.
c.
d.
e. False ['is']
['is', 'the']
none of the above Question 10
def inFileCount(fileName, searchStr):
inF = open(fileName)
contents = inF.read()
inF.close()
return contents.count(searchStr)
seuss = open('you.txt', 'w')
seuss.write('Today you are You, that is truer than true.' + '\n')
seuss.write('There is no one alive who is Youer than You.' + '\n')
seuss.close()
print(inFileCount('you.txt', 'You'))
seuss.close()
a.
b.
c.
d.
e. 0
1
2
3
none of the above Question 11a
8 points
Write a function named rectangle() that uses turtle graphics to
draw a
rectangle of specified dimensions. The function rectangle() takes
three
parameters:
i.
t, a turtle that is used for drawing
ii. size1, the length of the first (and third) side of the rectangle
iii. size2, the length of the second (and fourth) side of the rectangle
The function rectangle()
position and orientation
and orientation on exit.
state of the turtle. For
operations. should draw a rectangle beginning at the initial
of t, and should leave t with the same position
Do not make any assumptions about the initial
full credit you must use a loop for repeated Question 11b
12 points
Write a function named panels() that uses turtle graphics and the
function rectangle() (Question 11a) to draw a sequence of
rectangles of
specified size and orientation. Begin drawing each rectangle at the
initial
location of the passed turtle parameter. Rotate each rectangle
after the
first one counterclockwise by a specified angle. Make the second
(and
fourth) side of each rectangle twice the length of the first (and
third)
side.
The function panels() should repeatedly call rectangle() to draw
rectangles
of increasing size, rotated by a specified angle.
The function panels() takes 5 parameters:
i.
t, a turtle used for drawing
ii. initSize, the length of the short side of the first rectangle
iii. delta, the increase in length of the short side of successive
rectangles
iv. numPanels, the number of rectangles to draw
v.
angle, the number of degrees to rotate successive rectangles
If panels() is called by the following code, the graphic below
would be
correct output. (Hint: panels() should draw with the passed turtle,
whatever location and orientation the turtle is in.)
import turtle
s = turtle.Screen()
shelly = turtle.Turtle()
panels(shelly, 20, 15, 8, 20) Question 12
The letters a, e, i, o and u are the only vowels. Write a function
named
vowelUseDict() takes a string t as a parameter and computes and
returns a
dictionary with the number of words in t containing each vowel.
Assume that
the given text contains only lower case letters and white space.
Input:
Return: t, a string consisting of lower case letters and white space
a dictionary in which each vowel is a key and its value is
the number of words containing that vowel For example, the
following would be correct output.
text = 'like a vision she dances across the porch as the radio plays'
print(vowelUseDict(text))
{'e': 5, 'u': 0, 'o': 4, 'a': 6, 'i': 3}
Question 13
Write a function named longestWord() that find the length of the
longest
word in each line in a file and writes that length to a new file.
The function longestWord() takes two string parameters. The first
parameter
is the name of an input file that exists before longestWord() is
called.
The second parameter is the name of an output file that
longestWord()
creates and writes to.
Assume that the input file contains only letters and white space.
Assume
that the input file is in the current working directory and write
the
output file to that directory.
The function longestWord() should write a line to the output file
only if
the line in the input file is not empty, that is, it contains at least
one
word. For example, if the following is the content of the file
trouble.txt:
We surely got trouble
Right here in River City
Gotta figger out a way
To keep the young ones moral after school
The following function call:
inF = 'trouble.txt'
outF = 'troubleLongest.txt'
longestWord(inF, outF)
should create the file longestWord.txt with the content:
7
5
6
6
------------------------------------------
CS 100 Multiple choice questions 1-10
------------------------------------------
CS 100 sumOfCubes Challenge Problem 1
For example, let n = 10. The triplets of positive perfect cubes whose
sum is less than or equal to 10 are
1, 1, 1
1, 1, 8
Therefore, sumOfCubes(10) = 2.
------------------------------------------
Cs 100 This homework consists of 8 problems
You should submit this .py file with the blanks filled
'''
'''
'''
# The Bells
theBells = '''
Silver bells!
Golden bells!
On the moon!
How it swells!
How it dwells
Brazen bells!
Out of tune,
By the twanging
In the jangling
Of the bells,
Iron bells!
What a world of solemn thought their monody compels!
Is a groan.
All alone,
Rolls
Of the bells:
# Pablo Neruda
cantoXII = '''
'''
import string
def litCricFriend(wordList, text):
excluding punctuation.'''
# can use a list method to do the counting. Hint 2: lower case the
# of the indefinite articles 'a' and 'an' and the definite article
# 'the' in the two poems above. Print out the value returned by
# PROBLEM 8. Do the results show that Poe and Neruda use 'a'
and 'an'
# differently? Do the results show that Poe and Neruda use 'the'
# differently?
'''
------------------------------------------
CS 100 Write a function named uniqueWordsthat
------------------------------------------
CSC 110 Assignment 6 -- Voter Participation Data
1952
1533500
1392594
1116414
1956
1622500
1451375
1164104
...
a year
the estimated number of eligible voters for that year
Program Specification
Read the data from the file and write a report out to a new
file as follows:
Here is an example of what the report would look like for the first
file:
Number of years with less than 60% of registered voters casting ballots: 0
Percentage of years with more than 80% of registered voters casting ballots:
47.1%
Development Tips:
1. Use a loop to read the data from the file and process the
data. Only one loop is needed to do everything!
Grading
------------------------------------------
CSC 110 This program use Python 3 Objective
Objective:
Instructions:
4. Show the total sales for the company for the month --
thesumof all the numbers in the list. Once again, write a
function definition that uses a loop and an accumulator to
compute this sum.
Program Organization:
------------------------------------------
In Programming Exercise 1 in Chapter 1
vert a Roman numeral into its equivalent decimal number. Modify the
denition of the class roman'rype so that the data mem
bers are declared as protected. Use the class string to manipulate
the strings- Furthermore, overload the stream insertion and stream
extraction operators for easy input and output. The stream insertion
operator outputs the Roman numeral in the Roman format. Also,
include a member anction, decimalToRoman, that converts the
decimal number (the decimal number must be a positive integer) to an
equivalent Roman numeral format- Write the denition of the member
mction decimalToRoman. For simplicity, we aSSume that only the
letter I can appear in front of
another letter and that it appears only in ernt of the letters V and x.
For
example, 4 is represented as IV, 9 is represented as IX, 39 is
represented
as XXXIX, and 49 is represemed as XXXXIX. Also, 40 will be
represented
as moot, 19E!I will be represented as cm, and so on. Derive a class
extRomanType from the class romanType to do the
following. In the class extRomanType, overload the arithmetic
operators +, -, * , and / so that arithmetic operations can be performed
on Roman numerals- Also, overload the pre and postincrement and
decrement operators as member anctions of the class
extRomanType. To add (subtract, multiply, or divide) Roman
numerals, add (subtract,
multiply, or divide, respectively) their decimal representations and
then
convert the reSult to the Roman numeral format. For subtraction, if
the
rst number is smaller than the sec0nd number, output a message
saying
that, Because the first number is smaller than the second,
the numbers cannot be subtracted. Similarly, for division, the
numerator must be larger than the denominator. Use similar conven
tions for the increment and decrement operators. Write the denitions
of the anctions to overload the operators
descnbed in part b. Write a program to test your class extRoman'rype.
------------------------------------------
Quiz Write a method that computes the average
Question 3 (5 points)
Question 4 (5 points)
Provide the size of the array and the most likely data type.
Provide the specific Java nested loop
you would use to populate the array elements with random
values.
------------------------------------------
TECH 101 (a) What is critical thinking