Answer:
import csv
fileIn = open("data/bags.txt","r")
countPurse = 0
textFile= csv.reader(fileIn)
for bag in textFile:
if bag[
1
] == 'purse':
countPurse = countPurse + int(bag[6])
fileIn.close()
print("Number of purses:",countPurse)
Explanation:
I hope this helps!
Answer:
b. the same data type
Explanation:
Any number of variables can be declared in a statement as long as the variables have the same data type. For example:
1) int a,b,c,d,e;
Here each of the declared variables a,b,c,d,e have the type int.
2) char p,q,r,s,t,u,v,w;
In this case variables p to w all have the type char.
3) float x,y,z;
x,y and z are all of type float.
Design and implement an application that reads a string from the user, then determines and prints how many of each lowercase vowel (a, e, i, o, and u) appear in the entire string . Have a separate counter for each vowel. Also count and print the number of nonvowel characters .
SPECIFICATION OF PROMPTS, LABELS AND OUTPUT : Your code should use the prompt "enter string : ". After the input is read, there are six lines of output , each starting with a different label: "a: ", "e: ", "i: ", "o: ", "u: ", "other: " in that order. After each label is the required count.
For example: if "aardvark heebie jeebies" were read in,
The switch statement is an n-way branch. An n-way branch can branch to any of an arbitrary number ( n ) of branches. An if statement can branch two ways, whether the condition is true or false.
The example you gave is a great example of how how code is written can make the code make sense or not.
public void setQuiz( int quiz, int grade )
{
switch( quiz )
{
case 1: // if quiz == 1
grade1 = grade; //where was grade1 declared?
break; // otherwise execution will continue through the next case block
case 2: // if quiz == 2
grade2 = grade;
break;
}
}
The variable named in the switch statement is tested against each case statement and whichever case statement's value matches, the rest of the switch statement's code is executed. (That's why the break statements are needed) Usually switch statements are written with a default case at the end as a "catchall".
Answer:
Option e: The use of programmed decisions should be limited to noncritical situations.
Explanation:
A repetitive decision or routine that can be managed by developed business procedures or rules are known as programmed decisions. These kind of decisions are most often known for at certain points in a standard process, and are planned relying on recognized and easily identifiable terms. Programmed decisions generally do not demand much consideration or discussion, and can typically be automated to make certain consistency and save time for decision-makers.
So, the use of programmed decisions should not be limited to noncritical situations.