Answer:
import statistics as st # importing statistics package to calculate mean as st.
grades = {"John": [87,90,86.8], "Mary": [78, 81.5, 88.6],"Susan":[45,67,76]}
for key,value in grades.items():#iterating over the dictionary
average_score=st.mean(value)#calculating the mean of every student
gr="" empty string to store the grades
if average_score>=90: # nested if else if and statements for the grades in gr
gr="A"
elif average_score>=80.0 and average_score<90.0:
gr="B"
elif average_score>=70.0 and average_score<80.0:
gr="C"
elif average_score>=60.0 and average_score<70.0:
gr="D"
else :
gr="F"
print(str(key)+" "+str(average_score)+" "+str(gr)) #printing grades of every student.
Output:-Mary 82.7 B
John 87.93333333333334 B
Susan 62.666666666666664 D
Explanation:
1.In this program we are iterating over the dictionary grades.
2.Storing and calculating the mean of the scores of every student us statistics package.
3.Storing the grade in string gr and updating the gr according to the mean score
4.After that printing the grade of the student with their name and mean score.
When an expression containing a ____ is part of an if statement, the assignment is illegal.
a.
greater than sign
b.
double equal sign
c.
single equal sign
d.
Boolean value
Answer:
single equal sign
Explanation:
The if statement is used for check the condition.
syntax:
if(condition)
{
statement;
}
let discuss the option one by one for find the answer:
Option a: greater than sign
this assignment operator '>' is valid. it is used to create the condition like n>0, p>4.
Option b: double equal sign
this assignment operator '==' is valid. it is used to check the equal condition.
like 2 == 2.
Option c: single equal sign
this assignment operator '=' is not valid. it is used for assign the value to variable not for checking like a=2, in this 2 assign to a but it not apply the condition.
Option d: Boolean value
we can provide the Boolean value as well if Boolean is TRUE, if condition true otherwise false.
Therefore, the option c is correct option.
the largest distribution of software cost will be when in the programs life cycle?
Answer: Early
Explanation:
The largest distribution of software cost will be in the early stages of program life cycle. The different phases in the program life cycle are edit time, compile time, link time, distribution time, installation time, load time, and run time. So during early program life cycle we have editing stage which involves correcting the code , debugging earlier codes and addition of features into the code which leads to a large software cost
Write a program that generates two 3x3 matrices, A and B, withrandom values in the range [1, 100] and calculates the expression½A + 3B
Answer:
#include <bits/stdc++.h>
using namespace std;
int main() {
int A[3][3],B[3][3],res[3][3],i,j;
srand(time(0));//for seed.
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
int val=rand()%100+1;//generating random values in range 1 to 100.
int val2=rand()%100+1;
A[i][j]=val;
B[i][j]=val2;
}
cout<<endl;
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
res[i][j]=0.5*A[i][j]+3*B[i][j];//storing the result in matrix res.
}
}
cout<<"Matrix A is"<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<A[i][j]<<" ";//printing matrix A..
}
cout<<endl;
}
cout<<"Matrix B is"<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<B[i][j]<<" ";//printing matrix B..
}
cout<<endl;
}
cout<<"The result is"<<endl;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
cout<<res[i][j]<<" ";//printing the result..
}
cout<<endl;
}
return 0;
}
Output:-
Matrix A is
13 95 83
88 7 14
24 22 100
Matrix B is
11 13 95
48 35 20
68 100 18
The result is
39.5 86.5 326.5
188 108.5 67
216 311 104
Explanation:
I have created 2 matrices A and B and storing random numbers int the matrices A and B.Then after that storing the result in res matrix of type double to store decimal values also.Then printing the res matrix.
Given the following code. float dollars[5] = {1986.10, 240.99, 215.50, 75.00, float euros[5]; Give the C++ code that will fill the euros array with the corresponding euro value dollars array. So the first element of euros will be equivalent to the euro vat clement of the dollars array, etc. Use the following formula: 1 dollar = .92 euro
Answer:
#include <iostream>
using namespace std;
int main()
{
float dollars[5] = {1986.10, 240.99, 215.50, 75.00, 65.97};
float euros[5];
for(int i=0;i<5;i++){
euros[i] = dollars[i]*0.92;
}
for(int i=0;i<5;i++){
cout<<euros[i]<<endl;
}
return 0;
}
Explanation:
First include the library iostream for input/output.
then, create the main function and declare the arrays.
after that, take a for loop for traversing through dollars array and convert into euros by multiply each element with 0.92 value and store in the euros array with same index value as dollars array.
finally, take the for loop for print each element of the euros array.
What is DATE data type and its syntax and what is TIMESTAMP data type and its syntax in SQL language.Explain the difference between both of them .
Answer: The DATE datatype give us the particular date whereas TIMESTAMP gives us the date as well as the time as the particular moment.
Explanation:
DATE datatype gives us the date in the format yyyy-mm-dd. The timestamp format is yyyy-mm-dd hh:mm:ss. time stamp are of two types :
timestamp with time zone and timestamp without time zone.
Date is the date on that particular day whereas the timestamp is the date along with the specific time when the query is executed.
What are table buffers?
Answer:
Table buffers are tools used to avoid the process of accessing a database in servers.
A program written in ____ is the most basic circuitry-level language.
a.
Java
b.
machine language
c.
BASIC
d.
C
Answer:
The correct answer is B. Machine Language.
Explanation:
A programming language is a language that can be used to control the behavior of a machine. It consists of a set of syntactic and semantic rules that define its structure and the meaning of its elements, respectively.
A low level language is one that exposes the programmer to the operations of the machine, without contributing its own constructions. That is, in low level languages it will be possible to do everything the computer is capable of doing, but to achieve this the programmer will have to be intimately familiar with the details of the electronics in which his program runs.
An example of the low level language is the machine language that consists of binary instructions ready to run. The machine language is the one that gives orders to the machine, which are the fundamental operations for its operation. The computer only understands a language known as binary code or machine code, consisting of zeros and ones, which are easy to understand by the hardware of the machine. This language is much faster than high level languages. The disadvantage is that they are quite difficult to handle and use, besides having huge sources codes where finding a fault is almost impossible.
Final answer:
Machine language is the most basic circuitry-level language, written in binary code. High-level programming languages like C provide a more user-friendly alternative for programming.
Explanation:
The program written in machine language is the most basic circuitry-level language. Machine language is directly executed by the central processing unit (CPU) and is composed of binary code, which consists of zeros and ones. This type of programming is considered a low-level language, as opposed to high-level programming languages like Java, BASIC, or C, which require a compiler to convert their instructions into machine code that the CPU can understand and execute.
What is variable hoisting in JavaScript? Provide examples.
Answer:
before executing a code using javascript hoisting we can move any variable declaration to the top of the scope in a code.
Explanation:
It is to be remembered that hoisting works with declaration not with initialization.
example:
//initializing a variable s
var s = 2;
t = 4
elem.innerHTML = s + " " + t; // Display s and t values
// initializing a variable for hoisting
var t;
Which of the following is not a standard method called aspart of the JSP life cycle*
*jspInit()
*jspService()
*_jspService()
*jspDestroy()
Answer:
*jspService()
Explanation:
These are the steps in JSP life cycle.
1. Conversion JSP page to Servlet .
2.Compilation of JSP page(test.java)
3.Class is loaded (test.java to test.class)
4.Instantiation (Object is created)
5.Initialization (jspInit() method is only called once at the time of servlet generation )
6.Request processing(_jspService() method is used for serving requests by JSP)
7.JSP Cleanup (jspDestroy() method is used for removing JSP from use)
There is no *jspService() method in the JSP life cycle.
When multiple exceptions are caught in the same try statement and some of them are related through inheritance, does the order in which they are listed matter?
Answer:
Yes, the order in which the catch blocks are listed matter in case where multiple exceptions are caught in the same try statement and some of them are related through inheritance.
Explanation:
A try block may be followed by one or mutiple catch blocks. Each catch block should contain a separate exception handler. Thus, if we need to perform different tasks for the occurrence of different exceptions then we need to use java multiple catch blocks.
Every catch block should be ordered from the most particular to the most generic like catch for the NumberFormatException class must come before the catch for the Exception class.
Thus, the order in which the catch blocks are listed matter in case where multiple exceptions are caught in the same try statement and some of them are related through inheritance.
(TCO 4) What will be the value of input_value if the value 5 is input at run time? cin >> input_value; if (input_value > 5) input_value = input_value + 5; else if (input_value > 2) input_value = input_value + 10; else input_value = input_value + 15;
Answer:
15
Explanation:
if ..else is the conditional statement which is used to check the condition is true or not, if the condition is true that execute the particular statement and if not it moves to else part for execution.
if condition is more than two we can use continuous if else statement
Syntax:
if(condition)
{
statement;
}else if(condition)
{
statement;
}else
{
statement;
}
In the code:
The value of the input is 5.
first it goes to if part and check condition if 5 > 5, condition false it equal to 5 not greater than 5.
it then moves to else if part and check condition if 5 > 2, condition is true,
it execute the code inside the else if part. so, input_value become
5+10 which 15.
after that, program control terminate the if else statement it does not check further.
Some data files should be totally hidden from view, while others should have ____ so users can view, but not change, the data.
Answer
no-access properties
read-only properties
full-access properties
write-only properties
Answer:
read-only properties.
Explanation:
Only the read only properties can view but cannot change the data.The user don't have access to the no access properties, full-access properties can read and modify the data.The write only properties can only modify the data.So to only view the data the data should have read only properties.
Composite analog signals are SineWaves. True/false
Create an application program that will compute theradius and circumference of a circle. Write a Main class withHelper methods to prompt for and input the radius of acircle(getRadius), calculate thecircumference(calcCirc), and calculate thearea(calcArea) of a circle. Define the radius,area, and circumference in main which will call each calc method,passing radius to each one. Assume PI = 3.14159 or use theMath.PI builtin constant. Format theoutput to show two decimal places in the calculatedvalues.
Final answer:
An application to compute the radius and circumference of a circle requires creating a Main class with methods to input radius, calculate circumference, and area, formatting results to two decimal places using Math.PI.
Explanation:
To create an application that calculates the radius and circumference of a circle, you will need to define methods within your Main class. The getRadius method will prompt the user for input, calcCirc for calculating the circumference using the formula C = 2 * PI * r, and calcArea for calculating the area with A = PI * r * r. You should use the Math.PI constant for PI, and ensure all results are formatted to two decimal places.
Sample code structure in Java:
public class Main {
public static void main(String[] args) {
double radius = getRadius(); // prompts user and gets radius
double circumference = calcCirc(radius);
double area = calcArea(radius);
System.out.printf("Radius: %.2f\n", radius);
System.out.printf("Circumference: %.2f\n", circumference);
System.out.printf("Area: %.2f\n", area);
}
// Helper methods here
}
Ensure that you correctly use double data types for storing the input from the user, as well as the calculated values, since these can include decimal points.
Write a python function c that converts bitstring array back to an integer numpy array
Answer:
import numpy as np#importing numpy module with an alias np.
def c(bitstring_array):# defining function c.
num_integer=bitstring_array.dot(2**np.arange(bitstring_array.size)[::-1])#bitstring conversion.
return num_integer#returning integer array.
print("Enter bits")
Bit_l=input().split(" ")#enter space separated bitstring.
for i in range(len(Bit_l)):#iterating over the bitstring.
Bit_l[i]=int(Bit_l[i])
bitstring_array=np.array(Bit_l)
print(c(bitstring_array))#function call.
Output:
Enter bits
1 1 1 0 0 1
57
What are two reasons why tuples exist in Python?
A tuple is a sequence of grouped values. It serves to group, as if they were a single value, several values that, by their nature, must go together. The tuple type is immutable. A tuple cannot be modified once it has been created.
One of the reasons why there are tuples in phyton is that they are generally used to determinate that their content is not modified. They constitute a type of data widely used in the definition and call of functions and in other situations where it is necessary to use the capacity of tuples to be packaged and unpacked. The benefits of immutability are simplicity, reduced demand for storage space and high performance in processing, issues that exceed the lists.
Another reason why there are tuples on python is that tuples are faster than lists. If a constant set of values is defined and all that is going to be done is to iterate over them, it is better to use a tuple instead of a list.
Tuples in Python are immutable, which ensures data integrity and can be used as keys in dictionaries. They contribute to clearer, more maintainable code by supporting tuple assignment where multiple variables can be assigned in a single statement.
Reasons Why Tuples Exist in Python
One of the reasons why tuples exist in Python is because they are immutable. This means once a tuple is created, it cannot be modified, which is an essential feature in situations where a constant set of values is needed, and it prevents the data from being altered accidentally. Another reason for the existence of tuples is their ability to be used as keys in dictionaries due to their immutability and hashability. This allows for the sorting of lists of tuples and using them in data structures where the integrity of the key must be preserved.
Besides, tuples can increase code clarity and integrity in contexts where an immutable sequence of elements is expected. An example is passing arguments to a function; tuples can reduce the risk of bugs associated with mutable objects, hence reducing the potential for unexpected behavior due to aliasing.
Moreover, tuples can streamline tuple assignment in Python, where multiple variables can be assigned values simultaneously on the left side of an assignment statement. This can lead to cleaner, more readable code.
Do the following SQL questions. The resulting columns must all have descriptive names. You must show the result of the query. For example, if the query is:
Show the office id, the city, and the region
Your query should be:
select office, city, region
Answer:
We can use CREATE command to create tables with columns having descriptive names
Explanation:
Firstly, create a table using CREATE command in SQL. The syntax is as follows:
CREATE TABLE [table_name]
(
[col_name] [datatype]),
[col_name] [datatype]),
[col_name] [datatype]),
[col_name] [datatype])
)
Once the table is created, we can insert the data into table using INSERT command. It's syntax is as follows:
INSERT INTO table_name VALUES('', '', '')
if datatype is string, values must be entered within single quotes. If datatype is int, values are entered directly without using quotes.
Now, you can select the data from the table using SELECT command. It's syntax is as follows:
SELECT column-list FROM table_name
If you want to filter rows according to conditions, you can use WHERE command.
I have created sample table and inserted some data into it. Now, I applied some queries on it to select data from the table.
I have written in a text file and attached the same. Please find. Thank you!
.All of the following are true with the respect to implicitinvocation except:
A.it is based on the notion of bradcasting B.it is event-driven C.data exchange usesrepository D.components are instances ofabstractions
Answer: D) components are instances of abstraction
Explanation:
As, implicit invocation is the process by which it is used by the the software designer for styling the architecture of the software,where the event handling structured are formed in the system. The main aim of the implicit invocation is to separated the conceptual concern for maintaining or improving the ability of the software engineer. It is basically based on the notion of the broadcasting and based on the event driven. The components are the instance of the abstraction which are not used as the components in implicit invocation which are relinquished control the system over the computational performance,this is the major disadvantage of the implicit invocation.
Random access iterators are ____ iterators that can randomly process elements of a container.
A.
input
B.
forward
C.
bidirectional
Answer:
C. Bidirectional
Explanation:
If we want to access elements at an any random offset position then we can use random access iterators.They use the functionality 'as relative to the element they point to' like pointers.Random access iterators are Bidirectional iterators that can randomly process elements,pointer types are also random-access iterators.
Differentiate between global alignment and local alignment.
Answer: In global alignment an end to end alignment is made in the entire sequence however in local alignment a local region is found wit the highest level of similarity in their sequences.
Explanation:
Global alignment is more suitable for closely related sequences whereas local is suitable for divergent sequences.
global alignment is used for comparing genes base on same functionalities whereas local alignment is used to find sequences in DNA.
EMBOSS needle is a global alignment tool and BLAST is a local alignment tool
)1-bit sign, 8-bit exponent, 23-bit fraction and a bias of127 is used for ___________ Binary Floating PointRepresentation
o Double precision
o Single Precision
o All of above
o Half Precision
Answer: Single precision
Explanation:
A 1-bit sign, 8-bit exponent, 23-bit fraction and a bias of 127 is used for the single precision binary floating point representation. As, single precision is the smallest change that can be represented as floating point representation is called as precision. It is the computer format number, which occupies 32 bits in the computer memory.
The IEEE standard specify a binary 32 as:
Sign bit- 1 bit
Exponent width- 8 bits
Significant and precision- 24 bits (23 stored as explicitly)
The term asymptotic means the study of the function f as n becomes larger and larger without bound.
True
False
Answer:
False
Explanation:
The term asymptotic means approaching a value or curve arbitrarily closely
True / False Bit patterns have no intrinsic meaning.
Answer:
The given statement is True
Explanation:
Since, a bit pattern is a bit sequence, basically, data which as such has no intrinsic meaning.
Bit pattern is a bit sequence or sequentially arranged binary digits.
It is used to describe bit sequence in communication channels, memory or some other device.
Bit patterns are used to represent instructions, floating point numbers, signed/unsigned integers.
Examine the following code. What will be the output from the “printf()” statement below?
#define S_SIZE 10
char s[10] = { ‘g’ , ’o’ , ’m’ , ’i’ , ’z’ , ’z’ , ’o’ , ’u’ };
int j = 0;
for (j = S_SIZE -2; j > 4; j--) { printf( “%c”, s[j]); }
Using the definitions below (IGNORE ALL COMPILE ERRORS):
char s1 [ 50 ] = “JACK”, s2 [ 50 ]=”FRED”;
Answer:
uoz (with one space on the left most side)
Explanation:
#define is used to define macros, it just substitutes the value in the program.
For example:
#define S_SIZE 10
so, it put the value 10 where we write 'S_SIZE'.
then, character array define which has 8 elements.
Note: Array index starts from 0.
the, for loop is execute from 8 to j > 4( means 5).
it prints s[8] which not present in the array so, it prints blank space.
s[7] it prints 'u'
s[6] it prints 'o'
s[5] it prints 'z'
then the loop will be terminated.
Therefore, the answer is uoz with space on the leftmost side.
___ is an example of a function prototype.
A) float roi(int, double);
B) printf("%f", roi(3, amt));
C) roi(3, amt);
D) float roi( int yrs, double rate)
Answer:
A
Explanation:
B is a print statement.
C is a function invocation
D is a function declaration
A prototype is actually quite close to a declaration. The semi-colon at the end shows that no implementation will follow. Adding parameter names is allowed but would only be helpful for better understanding.
Write a program that converts temperatures in the Celsius scale to temperatures in the Fahrenheit scale. Your program should ask the user to supply the Celsius temperature, and convert the temperature entered to degrees Fahrenheit using the formula Fahrenheit = 1.8 * Celsius + 32. It should then display the Fahrenheit temperature.
Answer:
#include <iostream>
using namespace std;
int main()
{
float celsius;
cout<<"Enter the temperature in Celsius: ";
cin>>celsius;
float Fahrenheit = 1.8 * celsius + 32;
cout<<"The temperature in Fahrenheit is: "<<Fahrenheit<<endl;
}
Explanation:
first include the library iostream in the c++ programming.
Then, create the main function and declare the variable celsius.
cout is used to print the message on the screen.
cin is used to store the user enter value in the variable.
then, apply the formula for calculating the temperature in Fahrenheit
and store the result in the variable.
Finally, print the result.
A variable that can store an address is known as a(n) ____ variable.
A) register
B) pointer
C) static
D) extern
A variable that holds an address is known as a pointer variable.
Such variable "points" to location of memory in computer, the location can be another variable, primitive data type, object and more.
The answer is therefore B.
Hope this helps.
r3t40
What is disaster recovery? How could it be implemented at your school or work?
Answer:
Disaster recovery is a set of procedure/plans/actions which are put in place to protect an organization which is facing a disaster. In a technological terms, a government organizations facing cyber attack will follow certain counter measures to recover from cyber disaster. Similarly, in school a disaster recovery can be natural calamity or cyber threat at school's database.
To implement disaster recovery at school or work we must aware everyone with proper procedures and mock drills must be conducted so that people can act swiftly when a disaster occurs and speed up disaster recovery.
)Which of following can be thrown using the throwstatement?
? Error
? Throwable
? Exception
? RuntimeException
? All of Given
? None of given
Answer:
All of Given
Explanation:
The throw keywords can be used to throw any Throwable object. The syntax is :
throw <Throwable instance>
Note that Error and Exception are subclasses of Throwable while RuntimeException is a subclass of Exception. So the hierarchy is as follows:
Throwable
-- Error
-- Exception
-- RuntimeException
And all of these are valid throwable entities. As a result "All of Given" is the most appropriate option for this question.
Answer:
The answer is B: throwable
Explanation:
Throwable is the super class of all exceptions
Examine the following code and answer questions 7 below. IGNORE COMPILE ERRORS.
int j = 0;
for (j = 0; j <= 9; j++)
{ printf( “%d”, 1 + ( rand() % 5 )); }
7. What are the POSSIBLE range of numbers that will be printed by the “printf()” statement above?
Answer:
1 to 5 both included.
Explanation:
rand() is the function which is used to generate the random values within the range.
for example:
rand() % 10;
it means it generate the output from 0 to 9. if we add the 1 in the above code:
like 1 + (rand() % 10);
Then, the range is from 1 to 10, it increase the range from start and end as well.
in the question code, for loop is used to for executing statement 9 times.
rand() % 5
it generate the number from 0 to 4.
and 1 + ( rand() % 5 ))
it generate the output from 1 to 5
Therefore, the answer is 1 to 5.