which statements are true about Python functions?
a)Different functions cannot use same function name
b)a function always returns some value
c)different function cannot use the same variable names
d) function must use the same parameter names as the corresponding variables in the caller
what benefits does structuring a program through defining functions bring?
a) there is a possibility of reducing the number of variables and/or objects that must be managed at any cost at any one point
b)the program is easier to maintain
c)program with function executes faster
d)the program is easier to debug
in which scenario(s) should the sentinel value be set to -1 to terminate data entry
a)exam scores which can be negative but cannot be more than 100
b) participant name of participants who registered for a run
c)the rainfall data for days it rained
d)the weight of student waiting to undergo a medical examination.
suppose d = {"a": "apple", "b": "banana", "c": "cherry"}
which statement form a list [["a": "apple"], ["b": "banana"[, ["c": "cherry"]]
a) [[k,d[k]] for k in d.keys() ]
b) [[k,v] for k, v in d.items() ]
c) [[d,v] for v in d.values() ]
d) [[k,[0]], k[1]] for k in d]
In: Computer Science
At the end of a semester, the students’ grades for Business Data Analysis 1 were tabulated in the following 3×2 contingency table to see if there is any association between class attendance and grades received
# of Days Absent Grade Received Pass Fail 0-3 135 110 4-6 36 4 7-25 9 6
(a) Calculate the probability that a student selected at random:
i. Was absent for less than four days
ii. Was absent for less than seven days
iii. Passed iv. Passed given that he/she was absent for less than four days
v. Passed or was absent for less than four days
vi. Passed and was absent for less than four days. (b) Calculate the expected value for the number of days absence (c) Calculate the 95% confidence intervals for the
i. Percentage of students who passed
ii. Percentage of them who failed
iii. Interpret your findings
In: Statistics and Probability
1. Suppose X has a mean 5 and standard deviation 2. Let Y= 4x-3. Determine the mean and standard deviation of Y.
2. From an urn containing 6 red and 4 white marbles, 3 are drawn with replacement. Let X be the number of red marbles selected. Define Y as the square of the number of red marbles selected. Determine E(Y) and V(Y).
3.An examiner contains 10 multiple choice questions, each with
five choices. If a student guesses the answer to each question what
is the probability the students exam grade is a) at least 60%, b)
at least 80& c) 50% or less d) what is the students expected
grade?
4.A fair pair of dice are tossed. a) determine the probability the
fifth sum of seven occurs on the 15th toss. b) How many tosses of
the dice are needed to obtain the fifth sum of seven and with what
standard deviation.
In: Statistics and Probability
|
Student |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
|||
|
Test Scores |
Before |
24 |
20 |
18 |
3 |
19 |
33 |
32 |
21 |
34 |
||
|
After |
26 |
25 |
16 |
36 |
22 |
32 |
23 |
34 |
31 |
|||
|
i. Identify the claim and state the Ho and HI. |
||||||||||||
|
ii. Find the critical value. |
||||||||||||
|
iii. Calculate the test statistic. |
||||||||||||
iv. Make a decision to reject or fail to reject the Ho. (1 Mark)
v. Interpret the decision in the context of the original claim.
In: Statistics and Probability
Please complete the following problem.
Creating Data Sets
NINE students kept track of how many hours they played sports during August. Their mean was 24 hours. How many hours might each of the students have played sports? Your challenge is to make data sets to match the descriptions below. You MAY use a calculator for this activity.
• Create a different data set to match each of the conditions listed below.
• Please circle the median of each set and put a square around the mode, if any.
i. Mean is larger than the median:
ii. Median is larger than the mean:
iii. Mode is larger than the mean:
iv. Mean is larger than the mode:
v. Mode is larger than the median:
vi. Median is larger than the mode:
vii. Mean, median, and mode are equal, but every student did not play the same number of hours:
In: Statistics and Probability
Use quantifiers, predicates, and relations (i.e., predicates with more than one variable) to symbolize the statements. Let the domain of discourse be all students in this class. Let R ( x, y ) = x reads y, P ( x, y ) = x plays y, V ( x, y ) = x visited y, L ( x, y ) = x learned foreign language y, T ( x, y ) = x has taken y, C ( x, y ) = x is a course in department y, and D ( x, y ) = x is a department in school y.
In: Computer Science
Java: Determining whether a tree exists in a directed graph
I'm trying to figure out how to determine if a tree exists in a directed graph, I need help with the isTree() function. the code for the Bag class used is below the main code if it's needed.
import algs13.Bag;
import java.util.HashSet;
// See instructions below
public class MyDigraph {
static class Node {
private String key;
private Bag<Node> adj;
public Node (String key) {
this.key = key;
this.adj = new Bag<> ();
}
public String toString () { return key; }
public void addEdgeTo (Node n) { adj.add (n); }
public Bag<Node> adj () { return adj; }
}
Node[] node;
int V;
int E;
public static boolean DEBUG = false;
public MyDigraph (int V) {
if (V < 0) throw new IllegalArgumentException("Number of vertices in a Digraph must be nonnegative");
this.V = V;
this.E = 0;
this.node = new Node[V];
for (int i=0; i<V; i++) {
node[i] = new Node ("n" + (DEBUG ? i : StdRandom.uniform (100)));
}
}
public MyDigraph(Digraph G) {
this (G.V ()); // run the first constructor
for (int v=0; v<V; v++) {
for (int w : G.adj (v))
addEdge(v, w);
}
}
public MyDigraph(In in) {
this (in.readInt()); // run the first constructor
int E = in.readInt();
if (E < 0) throw new IllegalArgumentException("Number of edges in a Digraph must be nonnegative");
for (int i = 0; i < E; i++) {
int v = in.readInt();
int w = in.readInt();
addEdge(v, w);
}
}
public void addEdge(int v, int w) {
if (v < 0 || v >= V) throw new IndexOutOfBoundsException("vertex " + v + " is not between 0 and " + (V-1));
if (w < 0 || w >= V) throw new IndexOutOfBoundsException("vertex " + w + " is not between 0 and " + (V-1));
node[v].addEdgeTo (node[w]);
E++;
}
public String toString() {
StringBuilder s = new StringBuilder();
String NEWLINE = System.getProperty("line.separator");
s.append(V + " vertices, " + E + " edges " + NEWLINE);
for (int v = 0; v < V; v++) {
s.append(String.format("%s: ", node[v]));
for (Node w : node[v].adj ()) {
s.append(String.format("%s ", w));
}
s.append(NEWLINE);
}
return s.toString();
}
public void toGraphviz(String filename) {
GraphvizBuilder gb = new GraphvizBuilder ();
for (int v = 0; v < V; v++) {
gb.addNode (node[v]);
for (Node n : node[v].adj ())
gb.addEdge (node[v], n);
}
gb.toFile (filename);
}
// isTree returns true if the object graph rooted at node[s] is a (rooted out) tree
// (e.g. No duplicate paths or cycles)
public boolean isTree (int s) {
// TODO
return false;
}
====bag class code====
package algs13;
import stdlib.*;
public class Bag<T> implements Iterable<T> {
private int N; // number of elements in bag
private Node<T> first; // beginning of bag
// helper linked list class
private static class Node<T> {
public Node() { }
public T item;
public Node<T> next;
}
/**
* Create an empty stack.
*/
public Bag() {
first = null;
N = 0;
}
/**
* Is the BAG empty?
*/
public boolean isEmpty() {
return first == null;
}
/**
* Return the number of items in the bag.
*/
public int size() {
return N;
}
/**
* Add the item to the bag.
*/
public void add(T item) {
Node<T> oldfirst =
first;
first = new Node<>();
first.item = item;
first.next = oldfirst;
N++;
}
// check internal invariants
protected static <T> boolean check(Bag<T>
that) {
int N = that.N;
Bag.Node<T> first =
that.first;
if (N == 0) {
if (first !=
null) return false;
}
else if (N == 1) {
if (first ==
null) return false;
if (first.next
!= null) return false;
}
else {
if (first.next
== null) return false;
}
// check internal consistency of
instance variable N
int numberOfNodes = 0;
for (Bag.Node<T> x = first; x
!= null; x = x.next) {
numberOfNodes++;
}
if (numberOfNodes != N) return
false;
return true;
}
/**
* Return an iterator that iterates over the items in
the bag.
*/
public Iterator<T> iterator() {
return new ListIterator();
}
// an iterator, doesn't implement remove() since
it's optional
private class ListIterator implements
Iterator<T> {
private Node<T> current =
first;
public boolean hasNext() {
return current != null; }
public void remove() { throw new
UnsupportedOperationException(); }
public T next() {
if (!hasNext())
throw new NoSuchElementException();
T item =
current.item;
current =
current.next;
return
item;
}
}
/**
* A test client.
*/
public static void main(String[] args) {
StdIn.fromString ("to be or not to
- be - - that - - - is");
Bag<String> bag = new
Bag<>();
while (!StdIn.isEmpty()) {
String item =
StdIn.readString();
bag.add(item);
}
StdOut.println("size of bag = "
+ bag.size());
for (String s : bag) {
StdOut.println(s);
}
}
}
In: Computer Science
This task is about classes and objects, and is solved in Python 3.
We will look at two different ways to represent a succession of monarchs, e.g. the series of Norwegian kings from Haakon VII to Harald V, and print it out like this:
King Haakon VII of Norway, accession: 1905
King Olav V of Norway, accession: 1957
King Harald V of Norway, accession: 1991
>>>
Make a class Monarch with three attributes: the name of the monarch, the nation and year of accession. The class should have a method write () which prints out the information on a line like in the example. It should also have the method _init_ (…), so that you can create a Monarch instance by name, nation and year of accession as arguments. Example:
haakon = Monarch("Norway","King Haakon VII",1905)
Here, the variable haakon will be assigned to the Monarch object for King Haakon VII. Now the series of kings can be represented in a variable series of kings, that contains a list of the three monarchs, in the right order. Finally, the program will print the series of kings as shown above.
In: Computer Science
On May 19, 2012, a group of individuals, including Greg Hargus, rented a vessel (boat) from Ferocious and Impetuous, LLC d/b/a One Love Charters ("One Love"). Kyle Coleman captained the boat for One Love. While in Cruz Bay, Coleman saw two passengers throwing beer cans at Hargus. Coleman joined them and threw an empty plastic insulated coffee cup at Hargus, which hit Hargus on the head and allegedly caused him headaches and vision problems. Hargus brought suit against One Love, arguing that it was vicariously liable for Coleman's actions. Assuming Coleman was an agent of One Love, what is likely to be One Love's best defense to Hargus' vicarious liability theory? Explain.
In: Economics
Question 1. Compare / Contrast the anginas by creating a chart and then complete a list of 5 clinical manifestations associated with stable angina, unstable angina, and MI
Question 2. Create a patient teaching handout that incorporates a list of modifiable and nonmodifiable risk factors for coronary artery disease (CAD). Have students include pertinent teaching information about how patients could modify behaviors to address modifiable risk factors.
Question 3.Discuss at least 5 ways to help educate community members about the prevention of shock or sepsis, recognizing hypovolemic shock, and pre-hospital actions to take.
In: Nursing