please use python to solve this problem.
Math and String operations
Write a script to perform various basic math and string operations.
Use some functions from Python's math module. Generate formatted
output.
Basic math and string operations
Calculate and print the final value of each variable.
a equals 3 to the power of 2.5
b equals 2 b equals b + 3 (use +=)
c equals 12 c = c divided by 4 (use /=)
d equals the remainder of 5 divided by 3
Built-in functions abs, round, and min
Use abs, round, and min to calculate some values. These are all
Python built in functions (see: BIF ).
Print the difference between 5 and 7.
Print 3.14159 rounded to 4 decimal places.
Print 186282 rounded to the nearest hundred.
Print the minimum of 6, -9, -3, 0
Functions from the math module
Use some functions from Pythons math module to perform some
calculations.
Ask the user for a number (test with the value 7.6).
Print the square root of the number, rounded to two decimal places
(include an appropriate description).
Print the base-10 log of the number, rounded to two decimal places
(include an appropriate description)
(see https://docs.python.org/3/library/math.html).
Complex numbers
Do a calculation with complex numbers. Note that, while you might
be familiar with the notation convention commonly used within
mathematics for complex numbers (z = a + bi), Python uses the
notation convention used in electromagnetism and electrical
engineering (z = a + bj).
Assign z1 the value of 4 + 3j
Assign z2 the value of 2 + 2j
Assign z3 the value of z1 times z2
Print the value of z3
Add the following at the end of the script to show your results
In: Computer Science
Must be done in Ruby
Histogram
Create a Ruby program which reads a string of information and uses
a Hash to keep track of letter frequencies and then displays a
Histogram using this frequency information.
IN ORDER TO RECEIVE FULL CREDIT, YOUR CODE SHOULD PROPERLY PROCESS THE STRING INFORMATION, COUNTING FREQUENCIES BY USING A HASH.
A number of different program dialogues describe the program I am looking for.
Enter Data:
supercalifragilisticexpialadocious
A - 4 - ****
C - 3 - ***
D - 1 - *
E - 2 - **
F - 1 - *
G - 1 - *
I - 6 - ******
L - 3 - ***
O - 2 - **
P - 2 - **
R - 2 - **
S - 3 - ***
T - 1 - *
U - 2 - **
X - 1 - *
In: Computer Science
In: Computer Science
At Transport layer of Networks, we use segments to send data across.
1. Argue for using larger segments by discussing briefly why larger segments could be beneficial.
2. Then also argue why using small segments may be beneficial.
In: Computer Science
JAVA:
Display all even numbers between 1 and 20
--Optional write a program that reads in 20 numbers. A method with an int parameter should display whether the number is odd or even for the number passed
In: Computer Science
QUESTION 1a
A valid selection must be between 0 and 4. Enter the program
below and complete the while loop. Name the program
question1.cpp, compile and run it.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
// Fill in the code to define an integer variable called
selection
cout << "Please enter the choice of ticket "
<< "(a number from 1 to 4 or 0 to quit) " <<
endl;
cout << "Ticket Menu " << endl << endl;
cout << "1: Exclusive VIP area A " << endl;
cout << "2: VIP area B " << endl;
cout << "3: Elevated area " << endl;
cout << "4: General area R600 " << endl;
cout << "0: QUIT " << endl <<endl <<
endl;
cin >> selection ;
while (…………………) //complete the condition
{
cout << “Invalid choice – Please re-enter “;
cin >> selection;
}
cout << “You have selected option number “ <<
selection;
return 0;
}
QUESTION 1b
Modify question1.cpp by adding the code to calculate the cost
per order. Make use of a switch statement.
cout << "You have selected option number "“ <<;
cout << "How many tickets would you like?" <<
endl;
// Fill in the code to read in number
// Fill in the code to begin a switch statement
// that is controlled by selection
{
case 1: cost = number * 3000;
cout << "The total cost is R " << cost <<
endl;
break;
// Fill in the code for the case VIP area B ( R2000.00 each)
// Fill in the code for the case Elevated area (R1200.00
each)
// Fill in the code for the case General area (R600.00 each)
case 0: cout << " Please come again" << endl;
break;
default:
cout << “Invalid selection”
cout << " Try again please" << endl;
}
In: Computer Science
C++ programming: FUNCTIONS WITH DIFFERENT RETURN TYPES AND PARAMETERS
NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. If pensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% discount. Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for just a movie ticket alone. Write a program named question5b.cpp that will consist of two functions. The program must prompt the user for type of customer (‘p’ for pensioner, ‘s’ for student, ‘o’ for other). It must then call the relevant function according to that entry. The first function must receive the customer type and calculates discount for pensioners and students. The second function calculates the discount for customers that are not pensioners or students.
In: Computer Science
a) What are the most important principals for designing a good report or visual?
b) What would you specifically avoid in designing a good report or visual?
In: Computer Science
C++ Question
4. Formulate the following conditions
• A last name starts with the letter H.
• A last name starts with the letters Mac.
• A last name comes before "Jones".
In: Computer Science
Show that if all nodes in a splay tree are accessed in
sequential order, then the
total access time is O(N), regardless of the initial tree.
In: Computer Science
5.16 Implement function indexes() that takes as input a word (as a string) and a onecharacter letter (as a string) and returns a list of indexes at which the letter occurs in the word.
>>> indexes('mississippi', 's')
[2, 3, 5, 6]
>>> indexes('mississippi', 'i')
[1, 4, 7, 10]
>>> indexes('mississippi', 'a')
[]
In: Computer Science
Explain how the modular kernel design combines the benefits of both the layered and microkernel structures.
In: Computer Science
make a python script that has the following typed:
school = “cochise college”
place = “online”
Then do the following with the given parameters.Set the script to have a function that takes two parameters, school and place, have your function return the first 5 characters of each parameter value, utilizing a slice. Change the script to have a function that takes two parameters, school and place, have your function return the first character of each parameter, utilizing an index value. Then, Modify the script to have a function that takes two parameters, school and place, have your function return the last character of the variable place for each parameter, utilizing an index value. Next, modify the script to have a function that takes two parameters, school and place, have your function return the variables school and place in title form. Lastly, modify the python script to have a function that takes two parameters, school and place, have your function check to verify that ‘cochise’ is in the school parameter and ‘online’ is in the place parameter. If it is have the function return, ‘Great you go to Cochise College Online!’, else have the function return, ‘You should check out Cochise College Online!’
In: Computer Science
The objective is to read the last five lines of a file (text file) in Perl. I wrote down what I have written so far in Perl but I get an error message saying, "Can't open sample.txt: No such file or directory." The sample.txt file is located in the same directory that I am executing the perl scripts on the command line.
sample.txt
=============================================================
My
name
is
Jennifer
and
I
like
to
eat
tacos
de
birria
.
===========================================================
#!/usr/bin/perl
$filename= 'sample.txt';
open my $fh, "+>", $file or die "Can't open $filename: $!\n";
print "$file[-5]\n";
print "$file[-4]\n";
print "$file[-3]\n";
print "$file[-2]\n";
print "$file[-1]\n";
In: Computer Science
I'm doing a practice test and I can't seem to find the answers anywhere for these specific questions. If someone could please help clarify so I can learn that would be helpful!
1. Identify the true statements. Select ALL that apply.
a. Setters and getters are not required for public instance
variables.
b. A setter method is return-type void and takes a parameter of the same type as its field.
c. A getter method has the same return-type as the field it retrieves and takes no parameters.
d. Every private instance variable in a class definition must have a mutator method.
2.
private char gender;public class Person {
static int number;
//...
public static void main(String[] args) {
Person person;
//...
}
public static void callPerson(int hours) {
double payRate = 24.99;
}
}
The code above compiles okay. Refer to it to complete this matching exercise.
|
|
3. Identify the true statements. Select ALL that apply.
a. Static methods are also class methods
b. Static methods of a class can be called without instantiating the class.
c. A static method cannot access the data members of its own class.
d. A non-static method can be called from a static method.
4. What does the public visibility modifier mean?
a. means accessible from any class in the same package.
b. means accessible to the current program.
c. means accessible to any method in the class.
d. means accessible from any other classes.
5.
3. public class Person {
4. private double salary;
5. public Person() {
6. salary = 1000.0;
7. }
What type of constructor is illustrated by lines 5 through 7?
6. Identify the true statements. Select ALL that apply.
a. Constants in a class should be declared as final static.
b. Static variables and static methods of a class can be accessed by an object of that class and by the class name.
c. Static variables have a default value of null.
d. Anonymous objects are possible in Java.
7. What Java keyword sometimes used in a class definition refers to
the class itself?
In: Computer Science