Answer:
a)
void zero(double big_nums[]);
b)
zero(big_nums)
c)
int add1AndSum (int one_small[]);
d)
add1AndSum(one_small);
Explanation:
a)
void zero(double big_nums[]);
in this statement:
zero is the name of the function
void is used as the function does not return a value.
The function zero takes an array parameter i.e. big_nums[]
big_nums is the name of the array
big_nums[] array has a data type double
b)
zero is the name of the function
In part a) function zero has a parameter which is the array big_nums. So in order to call this function an array has to be passed as a parameter to this function.
So in this statmenent zero(big_nums) the array big_nums is passed to the zero function. You can also declare a new double type array with a different name in main() function and can pass this to the zero function as:
double array[ ] = { 20.6, 30.8, 5.1};
zero(array);
Look at the following program for the better understanding of part a) and b)
#include <iostream> //for using input output functions
using namespace std; //to access objects like cin cout
void zero (double big_nums[]); // function prototype
int main() { //start of main() function
double a[ ] = { 20.6, 30.8, 5.1}; // double type array a with elements
zero(a); } //calls zero function passing array a to the function
void zero(double big_nums[]){ // function zero with double type array big_nums as parameter and the function returns no value
int i;
for(i=0;i<3;++i) {
cout<<big_nums[i]; } } //prints the elements of array
c)
add1AndSum is the name of the function
int is used as the function does not return an integer.
The function add1AndSum takes an integer array parameter i.e. one_small[]
one_small is the name of the array
one_small[] array has a data type int
d)
add1AndSum is the name of the function
In part c) function add1AndSum has a parameter which is the array one_small. So in order to call this function an array has to be passed as a parameter to this function.
So in this statement add1AndSum(one_small); the array one_small is passed to the add1AndSum function. You can also declare a new int type array with a different name in main() function and can pass this to the add1AndSum function.
PROGRAM 8: Grade Converter! For this program, I would like you to create a function which returns a character value based on a floating point value as
Answer:
This function will return a character grade for every floating-point grade for every student in the class.
function grade( floatPoint ){
let text;
switch ( floatPoint ) {
case floatPoint < 40.0 :
text= " F ";
break;
case floatPoint == 40.0 :
text= " P ";
break;
case floatPoint > 40.0 && floatPoint <= 50.0 :
text= " C ";
break;
case floatPoint > 50.0 && floatPoint < 70.0 :
text= " B ";
break;
case floatPoint >=70.0 && floatPoint <= 100.0 :
text= " C ";
break;
default :
text= "Floating point must be between 0.0 to 100.0"
}
return text;
}
Explanation:
This javascript function would return a character grade for floating-point numbers within the range of 0.0 to 100.0.
What do Quadratic Selection sort, and Shell sort have in common?
They both used a/an_______based implementation in the standard form and are both relatively_____to the order of the data. The main similarity is that each one creates an environment in which a_____strategy works more efficiently.
1. blank
2. linked list
3. array
4. hybrid
5. tree
6. sensitive
7. insensitive
8. complex
9. modern
10. simple
11. retrograde
12. advanced
Answer:
a) An ARRAY ( 3 )
B) relatively INSENSITIVE ( 7 )
c) a HYBRID ( 4 )
Explanation:
They both used an array based implementation in the standard form and are both relatively insensitive to the order of the data. The main similarity is that each one creates an environment in which a hybrid strategy works more efficiently.
Quadratic selection sort is the sorting system that sorts out the smallest value in an entire list and arrange the list in such a way that the smallest value comes first.
a) Code a statement that creates an instance of an Account class using the default constructor and stores the object that’s created in a variable named account.
b) Code a statement that creates an instance of the Account class using a constructor that has two parameters named firstName and age, and store the object in a variable named account. Assume that variables with those names have already been declared and initialized so you can pass those variables to the constructor.
c) Code a statement that sets the value of the Age property of an Account object named account to the value in a variable named newAge.
d) Code a statement that will get the value of a public static field named Count that’s defined in the Account class, and store the value in a new int variable named count. Assume that you’ve already created an object from this class that’s named account.
Answer:
a)
Account account = new Account();
b)
Account account = new Account(firstName, age);
c)
account.Age = newAge;
d)
int count = Account.Count;
Explanation:
a)
new is the keyword which is used to create an object.
Account is the class name.
account is the name of an object of class Account.
account object is created to access the class Account.
Account() is the constructor of Account class. This is the default constructor and it has no parameters. Constructor has the same name as class. When a account object is created, constructor Account will be invoked.
b)
Account is the class name.
account is the name of an object of class Account.
Account() is the constructor of Account class. This is the parameterized constructor and it has two parameters i.e. firstName and age. Constructor has the same name as class. When a account object is created, constructor Account will be invoked.
c)
account.Age = newAge;
Here account is the object name. The Age property to access and update the private field of the Account class is set to the variable named newAge.
d)
This int count = Account.Count; statement gets the value of a public static field named Count that’s defined in the Account class, and stores the value in a new int variable named count.
Your car must have two red stoplights, seen from ______ feet in the daytime, that must come on when the foot brake is pressed.
A. 100
B. 200
C. 300
D. 400
Answer:
the answer is 300 feet in the daytime
CHALLENGE ACTIVITY 3.7.2: Type casting: Reading and adding values.
Assign totalowls with the sum of num_owls A and num_owls_B.
Sample output with inputs: 34
Number of owls: 7
1. total_owls -
2.
3. num_owls A - input
4. num_owls_B - input
5.
6. " Your solution goes here
7.
8. print("Number of owls:', total_owls)
Answer:
total_owls = 0
num_owls_A = int(input())
num_owls_B = int(input())
total_owls = num_owls_A + num_owls_B
print("Number of owls:", total_owls)
Explanation:
Initialize the total_owls as 0
Ask the user to enter num_owls_A and num_owls_B, convert the input to int
Sum the num_owls_A and num_owls_B and set it to the total_owls
Print the total_owls
avg_owls=0.0
num_owls_zooA = int(input())
num_owls_zooB = int(input())
num_owls_zooC = int(input())
num_zoos = 3
avg_owls = (num_owls_zooA + num_owls_zooB + num_owls_zooC) / num_zoos
print('Average owls per zoo:', int(avg_owls))
There is a problem while you are trying the calculate the average owls per zoo.
As you may know, in order to calculate the average, you need to get the total number of owls in all the zoos, then divide it to the number of zoos. That is why you need to sum num_owls_zooA + num_owls_zooB + num_owls_zooC and divide the result by num_zoos
Be aware that the average is printed as integer value. That is why you need to cast the avg_owls to an int as int(avg_owls)
Learn more about integer value on:
https://brainly.com/question/31945383
#SPJ6
The Adjacent Coins Problem Published on 2017-08-30 Consider N coins aligned in a row. Each coin is showing either heads or tails. The adjacency of these coins is the number of adjacent pairs of coins with the same side facing up. Write a program that given a non-empty zero-indexed array A consisting of N integers representing the coins, returns the maximum possible adjacency that can be obtained by reversing exactly one coin (that is, one of the coins must be reversed). Consecutive elements of array A represent consecutive coins in the row. Array A contains only 0s and/or 1s:
Answer:
Here is the JAVA code:
public class Main{
public static int solution(int[] A) { //method that takes non-empty array A consisting of 0s and 1s
int N = A.length; // number of 0s and 1s in array A
int r = 0; //result of adjacency
for (int i = 0; i < N - 1; i++; ) { // iterates through A
if (A[i] == A[i + 1]) //if i-th element of A is equal to (i+1)th element
r = r + 1; } //add 1 to the count of r
if (r == N-1) //for test cases like {1,1}
{return r-1; }
int max = 0; //to store maximum possible adjacency
for (int i = 0; i <N; i++) { //iterates through array
int c = 0;
if (i > 0) { //starts from 1 and covering the last
if (A[i-1] != A[i]) //checks if i-1 element of A is not equal to ith element of A
c = c + 1; //adds 1 to counter variable
else
c = c - 1; } //decrements c by 1
if (i < N - 1) {//starting with 0
if (A[i] != A[i + 1]) //checks if ith element of A is not equal to i+1th element of A
c = c + 1; //adds 1 to counter variable
else
c = c - 1; } //decrements c by 1
max = Math.max(max,c); } //finds the maximum of max and c
return r + max; } //returns result + maximum result
public static void main(String[] args) {
int[] A = {1, 1, 0, 1, 0, 0}; //sample array to test the method
System.out.println(solution(A));} } //calls the method passing array to it
Explanation:
The program works as follows:
A[] = {1, 1, 0, 1, 0, 0}
N = A.length
N = 6
The A has the following elements:
A[0] = 1
A[1] = 1
A[2] = 0
A[3] = 1
A[4] = 0
A[5] = 0
Program iterates through array A using for loop. Loop variable i is initialized to 0
if condition if (A[i] == A[i + 1]) checks
if (A[0] == A[0 + 1])
A[0] = 1
A[0 + 1] = A[1] = 1
They both are 1 so they are equal
r = r + 1;
Since the above if condition is true so 1 is added to the value of r Hence
r = 1
At each iteration of the loop the if condition checks whether the adjacent elements of A are equal. If true then r is incremented to 1 otherwise not.
So after all the iterations value of r = 2
if (r == N-1) evaluates to false because r=2 and N-1 = 5
So program moves to the statement:
for (int i = 0; i <N; i++)
This loop iterates through the array A
if (i > 0) condition checks if value of i is greater than 0. This evaluates to false and program control moves to statement:
if (i < N - 1) which makes if(0<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[0] != A[0 + 1]) -> if (A[0] != A[1])
We know that
A[0] = 1
A[1] = 1
So this evaluates to false and else part is executed:
value of c is decremented to 1. So c=-1
max = Math.max(max,c) statement returns the max of max and c
max = 0
c = -1
So max = 0
value of i is incremented to 1 so i = 1
At next step:
if (i < N - 1) which makes if(1<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[1] != A[1 + 1]) -> if (A[1] != A[2])
A[1] = 1
A[2] = 0
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = -1 + 1
Hence
Hence c= 0, max = 0 and i = 2
next step:
if (i < N - 1) which makes if(2<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[2] != A[2 + 1]) -> if (A[2] != A[3])
A[2] = 0
A[3] = 1
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = 0 + 1
c = 1
Hence
The statement max = Math.max(max,c) returns the max of max and c
max = 0
c = 1
So max = 1
Hence c= 1, max = 1 and i = 3
next step:
if (i < N - 1) which makes if(3<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[3] != A[3 + 1]) -> if (A[3] != A[4])
A[3] = 1
A[4] = 0
So the statement evaluates to true and following statement is executed
c = c + 1; The value of c is incremented to 1. So
c = 1 + 1
c = 2
Hence
The statement max = Math.max(max,c) returns the max of max and c
max = 1
c = 2
So max = 2
Hence c= 2, max = 2 i = 4
next step:
if (i < N - 1) which makes if(4<5) This evaluates to true and program control moves to statement
if (A[i] != A[i + 1]) which means:
if (A[4] != A[4+ 1]) -> if (A[4] != A[5])
A[4] = 0
A[5] = 0
So this evaluates to false and else part is executed:
value of c is decremented to 1. So c=1
max = Math.max(max,c) statement returns the max of max and c
max = 2
c = 1
So max = 2
value of i is incremented to 1 so i = 5
next step:
if (i < N - 1) which makes if(5<5) This evaluates to false
if (i > 0) evaluates to true so following statement executes:
if (A[i-1] != A[i])
if (A[5-1] != A[5])
if (A[4] != A[5])
A[4] = 0
A[5] = 0
This statement evaluates to false so else part executes and value of c is decremented to 1
Hence
max = 2
c = 0
So max = 2
value of i is incremented to 1 so i = 6
The loop breaks because i <N evaluates to false.
Program control moves to the statement:
return r + max;
r = 2
max = 2
r + max = 2+2 = 4
So the output of the above program is:
4
Given a number N, write a code to print all psoitive numbers less than N in which all adjacent digits differ by 1
Answer:
def lesser_adjacent_num ( N ):
N = int( N )
while N == True:
next = N - 1
print if next >= 0 ? next : break
Explanation:
The python function above called "lesser_adjacent_num" accepts an argument called "N" which is an integer. The function print the number "next" which is a number less than the N integer for every loop for the condition where N is not zero.
Scams where people receive fraudulent emails that ask them to supply account information are called ________.
Answer:
"Phishing" will be the correct approach.
Explanation:
This aspect of cyber attacks or fraud is called phishing, whereby clients or users are questioned for personally identifiable information about them.Attackers could very well-currently the most frequently use phishing emails to exchange malicious programs that could operate effectively in what seems like several different ways. Others would get victims to steal user credentials including payment details.EAPOL operates at the network layers and makes use of an IEEE 802 LAN, such as Ethernet or Wi-Fi, at the link level.
A. True
B. False
What caused the substantial schedule delay of software development for the Jaguar project? (b) How did the software problem impact the project? (c) If you were the project manager, what would you have done differently to prevent the software problem from happening?
Answer:
ES LA B
Explanation:
list three components of a computer system
Q2) Answer the following:
1- Expression d=i++; causes:
a. The value of i incremented by 1
b- The value of i assigned to d
C- The value of i assigned to d then i incremented by 1
d- The value ol i incremented by 1 then assigned to d.
CO
SA
Answer:
D
Explanation:
The value of i is incremented by one then assigned to d
Write the program to compute how many gallons of paint are needed to cover the given square feet of walls. Assume 1 gallon can cover 350.0 square feet. So gallons =the square feet divided by 350.0. If the input is 250.0, the output should be: 0.714285714286
Answer:
Here is the Python and C++ program.
Python program:
gallons_paint=0.0 #declare and initialize gallons_paint
wall_area = float(input()) #prompts user to enter wall area
gallons_paint = wall_area / 350 #formula to compute gallons of paint needed to cover the given square feet of walls
print(gallons_paint) #display the result
C++ program:
#include <iostream> //to use input output functions
using namespace std; //to identify objects like cin cout
int main(){ //start of main() function body
float wall_area,gallons_paint=0; //declare variables
cin>>wall_area; //reads input wall area from user
gallons_paint=wall_area/350; //formula to compute gallons of paint needed to cover the given square feet of walls
cout<<gallons_paint;} //print the result
Explanation:
The program prompts the user to enter the area of wall and stores the input value in wall_area
Suppose the user enters 250 as wall area
The the formula gallons_paint=wall_area/350; works as follows:
gallons_paint = wall_area/350;
= 250/350
= 0.71428
gallons_paint = 0.71428
So the output is:
0.71428
The screenshot of the program along with its output is attached.
What is resource management in Wireless Communication? Explain its advantages
Answer:
Wireless resources management is communication to address they faster response time.
Explanation:
Wireless communication that provide bandwidth, and transmission reliable, towards development.
This communication is discovered to the date and have consumed physical layer of available wireless resources.
Wireless communication management all this critical topic and the management techniques, and limited device battery power.
Communication as the address channel loss, and multi path .
Communication are the latest resources allocation and new or next generation and technologies.
Wireless communication theoretical concepts in a manner, and the necessary mathematical tools and fundamental tools.
Wireless communication device industries up to date of the topic,readers are benefit from a basic.
list 2 forms of computer output
Answer:
Soft copy like audio
Hard copy e.g printouts
Explanation:
The penalties for ignoring the requirements for protecting classified information when using social networking services are _________________ when using other media and methods of dissemination.
The penalties for ignoring the requirements for protecting classified information when using social networking services are the same when using other media and methods of dissemination.
The penalties are the same because it does not matter what the medium used, the effect is that classified information and confidential details have been left unguarded and exposed.
When in hold of such information, it is not okay to leave it unguarded or exposed. A person who is found guilty of disclosure of classified materials would face sanctions such as:
They would be given criminal sanctionsThey would face administrative sanctionsThey would also face civil litigationsRead more on https://brainly.com/question/17207229?referrer=searchResults
An organization is building a new customer services team, and the manager needs to keep the team focused on customer issues and minimize distractions. The users have a specific set of tools installed, which they must use to perform their duties. Other tools are not permitted for compliance and tracking purposes. Team members have access to the Internet for product lookups and to research customer issues. Which of the following should a security engineer employ to fulfill the requirements for the manager?a. Install a web application firewallb. Install HIPS on the team's workstations.c. implement containerization on the workstationsd. Configure whitelisting for the team
Answer:
a
Explanation:
because they need to protect the organization's information
Define Proportional spacing fornt.
Answer:
Alphabetic character spacing based on the width of each letter in a font. ... Proportional spacing is commonly used for almost all text. In this encyclopedia, the default text is a proportional typeface, and tables are "monospaced," in which all characters have the same fixed width.
hope this answer helps u
pls mark me as brainlitest .-.
The breastbone or ________________ extends down the chest.
Answer:
The sternum or breastbone is a long flat bone located in the central part of the chest.
The sternum or breastbone is a long flat bone located in the central part of the chest.
In the middle of the chest, there is a long, flat bone known as the sternum or breastbone. It forms the front of the rib cage and is joined to the ribs by cartilage, assisting in the protection of the heart, lungs, and major blood arteries from harm. It is one of the longest and largest flat bones in the body, somewhat resembling a necktie. The manubrium, body, and xiphoid process are its three regions.
Therefore, the sternum or breastbone is a long flat bone located in the central part of the chest.
Learn more about the breastbone here:
https://brainly.com/question/32917871.
#SPJ2
Giving BRANLIEST IFFF CORRECT
Which type of chart or graph shows the contribution of each item in a total of 100%?
Bar graph
Column chart
Line graph
Pie chart
Answer:
pie chart
Explanation:
pie chart shows percentage per item
Answer:
pie chart
Explanation:
Suppose that the tuition for a university is $10,000 this year and increases 4% every year. In one year, the tuition will be $10,400. Write a program using for loop that computes the tuition in ten years and the total cost of four years’ worth of tuition after the tenth year.
Answer:
The programming language is not stated; however, I'll answer using Python programming language (See attachment for proper format)
tuition = 10000
rate = 0.04
for i in range(1,15):
tuition = tuition + tuition * rate
if i <= 10:
print("Year "+str(i)+" tuition:",end=" ")
print(round(tuition,2))
if i == 14:
print("Tuition 4th year after:",end=" ")
print(round(tuition,2))
Explanation:
The first 2 lines initializes tuition and rate to 10000 and 0.04 respectively
tuition = 10000
rate = 0.04
The next line iterates from year 1 to year 14
for i in range(1,15):
This line calculates the tuition for each year
tuition = tuition + tuition * rate
The next 3 lines prints the tuition for year 1 to year 10
if i <= 10:
print("Year "+str(i)+" tuition:",end=" ")
print(round(tuition,2))
The next 3 lines prints the tuition at the 4th year after year 10 (i.e. year 14)
if i == 14:
print("Tuition 4th year after:",end=" ")
print(round(tuition,2))
Bharath has made a table of content for his document in Open Office, in which he wants to make few changes, but he is unable to make the changes. Give reason. Explain how he can make the necessary changes
Answer:
H cannot update it because it is probably protected.
If you cannot click in the table of contents, it is probably because it is protected. To disable this protection, choose Tools > Options > OpenOffice.org Writer > Formatting Aids, and then select Enable in the Cursor in protected areas section. If you wish to edit the table of contents without enabling the cursor, you can access it from the Navigator.
Explanation:
. To update a table of contents when changes are made to the document:
Right-click anywhere in the TOC.
From the pop-up menu, choose Update Index/Table. Writer updates the table of contents to reflect the changes in the document.
You can also update the index from the Navigator by right-clicking on Indexes > Table of Contents1 and choosing Index > Update from the pop-up menu.
Suppose there are 4 nodes sharing a broadcast channel using TDMA protocol. Suppose at time t=0: • Node 1 has 6 frames to transmit, • Node 2 has 4 frames to transmit, • Node 3 has 8 frames to transmit, • Node 4 has 3 frames to transmit. Maximum number of frames which can be transmitted by a node in a time slot = 3 The time required to transmit one frame = 1 Second Explain how TDMA protocol works to complete this task? How much time will it take to transmit all frames?
Answer:
Following are the description of the given nodes:
Explanation:
The Multiple Access frequency - division facilitates control by granting every node a fixed time slot. Also, every slot seems to be identical in width. Its whole channel bandwidth is often used in every channel node. Compared to FDMA it takes more time.
Time slot=3 frames for all the above scenario
In the first point, It is reserved the node 1, and as well as 3 frames were also transmitted 1. In the second point, It is reserved the node 2, and as well as 3 frames are transmitted. In the third point, It is reserved 3 nodes, and as well as 3 frames were transmitted. In the fourth point, It is reserved 4 slots and the transmit 3 frames. In the fifth point, It stores the slot 1 and the transmit 3 frames. In the sixth point, It stores the slot 2 and the transmit 1 frame. In the seventh point, It stores the slot 3 and the transmit 3 frames. In the Eight points, It stores the slot 3 and the transmit 2 frames.Time interval = number of frames in first slot Time to send 1 frame number of images
[tex]= 8 \times 3 \times 1 \\\\ = 8 \times 3 \\\\= 24 \ seconds[/tex]
Although Python provides us with many list methods, it is good practice and very instructive to think about how they are implemented. Implement a Python methods that works like the following: a. count b. in: return True if the item is in the list c. reverse d. index: return -1 if the item is not in the list e. insert
Answer:
Here are the methods:
a) count
def count(object, list):
counter = 0
for i in list:
if i == object:
counter = counter + 1
return counter
b) in : return True if the item is in the list
def include(object, list):
for i in list:
if i == object:
return True
return False
c) reverse
def reverse(list):
first = 0
last = len(list)-1
while first<last:
list[first] , list[last] = list[last] , list[first]
first = first + 1
last = last - 1
return list
d) index: return -1 if the item is not in the list
def index(object, list):
for x in range(len(list)):
if list[x] == object:
return x
return -1
e) insert
def insert(object, index, list):
return list[:index] + [object] + list[index:]
Explanation:
a)
The method count takes object and a list as parameters and returns the number of times that object appears in the list.
counter variable is used to count the number of times object appears in list.
Suppose
list = [1,1,2,1,3,4,4,5,6]
object = 1
The for loop i.e. for i in list iterates through each item in the list
if condition if i == object inside for loop checks if the item of list at i-th position is equal to the object. So for the above example, this condition checks if 1 is present in the list. If this condition evaluates to true then the value of counter is incremented to 1 otherwise the loop keeps iterating through the list searching for the occurrence of object (1) in the list.
After the complete list is moved through, the return counter statement returns the number of times object (i.e. 1 in the example) occurred in the list ( i.e. [1,1,2,1,3,4,4,5,6] ) As 1 appears thrice in the list so the output is 3.
b)
The method include takes two parameters i.e. object and list as parameters and returns True if the object is present in the list otherwise returns False. Here i have not named the function as in because in is a reserved keyword in Python so i used include as method name.
For example if list = [1,2,3,4] and object = 3
for loop for i in list iterates through each item of the list and the if condition if i == object checks if the item at i-th position of the list is equal to the specified object. This means for the above example the loop iterates through each number in the list and checks if the number at i-th position in the list is equal to 3 (object). When this if condition evaluates to true, the method returns True as output otherwise returns False in output ( if 3 is not found in the list). As object 3 is present in the list so the output is True.
c) reverse method takes a list as parameter and returns the list in reverse order.
Suppose list = [1,2,3,4,5,6]
The function has two variables i.e. first that is the first item of the list and last which is the last item of the list. Value of first is initialized to 0 and value of last is initialized to len(list)-1 where len(list) = 6 and 6-1=5 so last=5 for the above example. These are basically used as index variables to point to the first and last items of list.
The while loop executes until the value of first exceeds that of last.
Inside the while loop the statement list[first] , list[last] = list[last] , list[first] interchanges the values of elements of the list which are positioned at first and last. After each interchange the first is incremented to 1 and last is decremented to 1.
For example at first iteration:
first = 0
last = 5
list[0] , list[5] = list[5] , list[0]
This means in the list [1,2,3,4,5,6] The first element 1 is interchanged with last element 6. Then the value of first is incremented and first = 1, last = 4 to point at the elements 2 and 5 of the list and then exchanges them too.
This process goes on until while condition evaluates to false. When the loop breaks statement return list returns the reversed list.
d) The method index takes object and list as parameters and returns the index of the object/item if it is found in the list otherwise returns -1
For example list = [1,2,4,5,6] and object = 3
for loop i.e. for x in range(len(list)): moves through each item of the list until the end of the list is reached. if statement if list[x] == object: checks if the x-th index of the list is equal to the object. If it is true returns the index position of the list where the object is found otherwise returns -1. For the above examples 3 is not in the list so the output is -1
e) insert
The insert function takes as argument the object to be inserted, the index where the object is to be inserted and the list in which the object is to be inserted.
For example list = [0, 1, 2, 4, 5, 6] and object = 3 and index = 3
3 is to be inserted in list [1,2,4,5] at index position 3 of the list. The statement:
return list[:index] + [object] + list[index:]
list[:index] is a sub list that contains items from start to the index position. For above example:
list[:index] = [0, 1, 2]
list[index:] is a sub list that contains items from index position to end of the list.
list[index:] = [4, 5, 6]
[object] = [3]
So above statement becomes:
[0, 1, 2] + [3] + [4, 5, 6]
So the output is:
[0, 1, 2, 3, 4, 5, 6]
Describe how asymmetric encryption is used to send a message from User A to User B that assures data confidentiality, authentication, and integrity. Be specific as to the keys used and how they achieve the three goals.
Answer:
Find the explanation below.
Explanation:
Asymmetric encryption is a system of communication in technology between two parties where keys which are variable values coined by an algorithm are used to encrypt and decrypt the messages between the sender and receiver. The two types of keys used in this process are the public and private keys. The public keys can be used by anyone to encrypt messages which are then sent to the receiver who decrypts the message using his private keys. The private keys on the other hand are only shared by the person who first set up the key. In sending messages this way, the receiver's public key is gotten from a public directory, and the message encrypted by the sender. The receiver can then decrypt the message using his private keys. But if the message is encrypted using a private key, it is decrypted by the receiver with a public key.
The one-way nature of this style of communication ensures data integrity and confidentiality since users are not required to disclose their keys and only the two parties can access the message. The two end users also preserve the right to authenticate the keys. The transport layer security protocol makes use of asymmetric encryption.
b. Does “refactoring” mean that you modify the entire design iteratively? If not, what does it mean?
Explanation:
Refactoring consists of improving the internal structure of an existing program's source code, while preserving its external behavior.
Write a script named dif.py. This script should prompt the user for the names of two text files and compare the contents of the two files to see if they are the same. If they are, the script should simply output "Yes". If they are not, the script should output "No", followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file, including whitespace and punctuation. The loop should break as soon as a pair of different lines is found.
Answer:
Following are the code to this question:
f1=input('Input first file name: ')#defining f1 variable that input file 1
f2=input('Input second file name: ')#defining f2 variable that input file 2
file1=open(f1,'r')#defining file1 variable that opens first files by using open method
file2=open(f2,'r')#defining file1 variable that opens second files by using open method
d1=file1.readlines()#defining d1 variable that use readlines method to read first file data
d2=file2.readlines()#defining d2 variable that use readlines method to read second file data
if d1==d2:#defining if block that check file data
print('Yes')#when value is matched it will print message yes
exit# use exit keyword for exit from if block
for j in range(0,min(len(d1),len(d2))):#defining for loop that stores the length of the file
if (d1[j]!=d2[j]):#defining if block that check value is not matched
print('No')#print the message "NO"
print("mismatch values: ",d1[j]," ",d2[j])#print file values
Output:
please find the attached file.
Explanation:
code description:
In the above code, the "f1 and f2" variable is used for input value from the user end, in which it stores the file names. In the next step, the "file1 and file2" variable is declared that uses the open method to open the file. In the next line, the"d1 and d2" variable is declared for reads file by using the "readlines" method. Then, if block is used that uses the "d1 and d2" variable to match the file value if it matches it will print "yes", otherwise a for loop is declared, that prints files mismatch values.Answer:
first = input("enter first file name: ")
second = input("enter second file name: ")
file_one = open(first, 'r')
file_two = open(second, 'r')
if file_one.read() == file_two.read():
print("Both files are the same")
else:
print("Different files")
file_one.close()
file_two.close()
Giving Brainliest IFFF CORRECT
Jonathan needs to create a chart that shows the change in weight he can lift in weightlifting class. Which chart or graph should he use?
Bar graph
Column chart
Line graph
Pie chart
Answer:
line graph
Explanation:
the change in weight is linear
Answer:
Line Graph
Explanation:
Linear Weight change
Write a method named coinFlip that accepts as its parameter a string holding a file name, opens that file and reads its contents as a sequence of whitespace-separated tokens. Assume that the input file data represents results of sets of coin flips. A coin flip is either the letter H or T, or the word Heads or Tails, in either upper or lower case, separated by at least one space. You should read the sequence of coin flips and output to the console the number of heads and the percentage of heads in that line, rounded to the nearest whole number. If this percentage is 50% or greater, you should print a "You win!" message; otherwise, print "You lose!". For example, consider the following input file: H T H H T Tails taIlS tAILs TailS heads HEAds hEadS For the input above, your method should produce the following output: 6 heads (50%) You win!
Answer:
Here is the JAVA program:
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException{ //the start of main() function body, it throws an exception that indicates a failed attempt to open the file
Scanner input = new Scanner(new File("file.txt")); //creates a Scanner object and a File object to open and scan through the file.txt
coinFlip(input); } //calls coinFlip method
public static void coinFlip(Scanner input) { //coinFlip method that accepts as its parameter a string input holding a file name
while(input.hasNextLine()) { //iterates through the input file checking if there is another line in the input file
Scanner scan = new Scanner(input.nextLine()); //creates a Scanner object
int head = 0; // stores count of number of heads
int count = 0; //stores count of total number of tokens
while(scan.hasNext()) { //iterates through the sequence checking if there is another sequence in the input file
String token= scan.next(); // checks and returns the next token
if (token.equalsIgnoreCase("H")||token.equalsIgnoreCase("Heads")) { //compares H or Heads with the tokens in file ignoring lower case and upper case differences
head++; } //if a token i.e. any form of heads in file matches with the H or Heads then add 1 to the number of heads
count++; } //increment to 1 to compute total number of counts
double result = Percentage(head, count); //calls Percentage method passing number of heads and total counts to compute the percentage of heads
System.out.println(head + " heads " + "(" + result +"%)"); // prints the number of heads
if(result >= 50.00) { //if the percentage is greater or equal to 50
System.out.println("You win!");} //displays this message if above if condition is true
else //if the percentage is less than 50
{System.out.println("You lose!");} } } //displays this message if above if condition is false
public static double Percentage(int h, int total) { //method to compute the percentage of heads
double p = (double)h/total* 100; // divide number of heads with the total count and multiply the result by 100 to compute percentage
return p; } } //returns result
Explanation:
The program is well explained in the comments mentioned with each line of the above code. I will explain how the method coinFlip works.
Method coinFlip accepts a string holding a file name as its parameter. It opens that file and reads its contents as a sequence of tokens. Then it reads and scans through each token and the if condition statement:
if (token.equalsIgnoreCase("H")||token.equalsIgnoreCase("Heads"))
checks if the each token in the sequence stored in the file is equal to the H or Heads regardless of the case of the token. For example if the first token in the sequence is H then this if condition evaluates to true. Then the head++ statement increments the count of head by 1. After scanning each token in the sequence the variable count is also increased to 1.
If the token of the sequence is HeAds then this if condition evaluates to true because the lower or upper case difference is ignored due to equalsIgnoreCase method. Each time a head is found in the sequence the variable head is incremented to 1.
However if the token in the sequence is Tails then this if condition evaluates to false. Then the value of head variable is not incremented to 1. Next the count variable is incremented to 1 because this variable value is always incremented to 1 each time a token is scanned because count returns the total number of tokens and head returns total number of heads in the tokens.
Percentage method is used to return the percentage of the number of heads in the sequence. It takes head and count as parameters (h and total). Computes the percentage by this formula h/total* 100. If the result of this is greater than or equal to 50 then the message You win is displayed otherwise message You lose! is displayed in output.
11. Which of the following is word processing
software?
Hope this is correct
HAVE A GOOD DAY!