Answer:
The output is: Your cost is 100
Explanation:
Given
The above code snippet
and
[tex]cost = 100[/tex]
Required
Determine the output of the code
if cost < 70 or cost > 150
The above condition checks if cost is less than 70 or cost is greater than 150
This condition is false because 100 is neither less than 70 nor is it greater than 150
So, the else statement will be executed.
discount = cost
Which means
discount = 100
So, the print instruction will print: Your cost is 100
List the three ways Python can handle colors.
Answer:
Try using coloramapackage in python for text colour & has cross platform support across Windows & Linux. It can also be used in conjunction with existing ANSI libraries like Termcolor. This approach would be better than manually printing ASCII sequences for text colouring on terminals. from colorama import Fore, Back, Style
Explanation:
Write a program which will enter information relating to a speeding violation and then compute the amount of the speeding ticket. The program will need to enter the posted speed limit, actual speed the car was going, and whether or not the car was in a school zone and the date of the violation. Additionally, you will collect information about the driver (see output for specifics). The way speeding tickets are computed differs from city to city. For this assignment, we will use these rules, which need to be applied in this order:
Answer:
In Java:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
float speedlimit, actualspeed;
String ddate;
int schoolzone;
System.out.print("Speed Limit: ");
speedlimit = input.nextFloat();
System.out.print("Actual Speed: ");
actualspeed = input.nextFloat();
System.out.print("Date: ");
ddate = input.nextLine();
System.out.print("School Zone (1-Yes): ");
schoolzone = input.nextInt();
float ticket = 75;
ticket += 6 * (actualspeed - speedlimit);
if(actualspeed - speedlimit > 30){
ticket+=160;
}
if(schoolzone == 1){
ticket*=2;
}
System.out.print("Date: "+ddate);
System.out.print("Speed Limit: "+speedlimit);
System.out.print("Actual Speed: "+actualspeed);
System.out.print("Ticket: "+ticket);
}
}
Explanation:
See attachment for complete program requirements
This declares speedlimit and actualspeed as floats
float speedlimit, actualspeed;
This declares ddate as string
String ddate;
This declares schoolzone as integer
int schoolzone;
This prompts the user for speed limit
System.out.print("Speed Limit: ");
This gets the speed limit
speedlimit = input.nextFloat();
This prompts the user for actual speed
System.out.print("Actual Speed: ");
This gets the actual speed
actualspeed = input.nextFloat();
This prompts the user for date
System.out.print("Date: ");
This gets the date
ddate = input.nextLine();
This prompts the user for school zone (1 means Yes, other inputs means No)
System.out.print("School Zone (1-Yes): ");
This gets the input for schoolzone
schoolzone = input.nextInt();
This initializes ticket to $75
float ticket = 75;
This calculates the additional cost based on difference between speed limits and the actual speed
ticket += 6 * (actualspeed - speedlimit);
If the difference between the speeds is greater than 30, this adds 160 to the ticket
if(actualspeed - speedlimit > 30){
ticket+=160;
}
If it is in a school zone, this doubles the ticket
if(schoolzone == 1){
ticket*=2;
}
The following print the ticket information
System.out.print("Date: "+ddate);
System.out.print("Speed Limit: "+speedlimit);
System.out.print("Actual Speed: "+actualspeed);
System.out.print("Ticket: "+ticket);
Write a program with the total change amount as an integer input, and output the change using the fewest coins, one coin type per line. The coin types are Dollars, Quarters, Dimes, Nickels, and Pennies. Use singular and plural coin names as appropriate, like 1 Penny vs. 2 Pennies. The input should be an integer, with the unit as "cents". For example, the input of 126 refers to 126 cents. 1 Dollar = 100 cents 1 Quarter = 25 cents 1 Dime = 10 cents 1 Nickel = 5 cents 1 Penny = 1 cent Ex: If the input is:
Answer:
In Python:
cents = int(input("Cents: "))
dollars = int(cents/100)
quarters = int((cents - 100*dollars)/25)
dimes = int((cents - 100*dollars- 25*quarters)/10)
nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)
pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels
if not(dollars == 0):
if dollars > 1:
print(str(dollars)+" dollars")
else:
print(str(dollars)+" dollar")
if not(quarters == 0):
if quarters > 1:
print(str(quarters)+" quarters")
else:
print(str(quarters)+" quarter")
if not(dimes == 0):
if dimes > 1:
print(str(dimes)+" dimes")
else:
print(str(dimes)+" dime")
if not(nickels == 0):
if nickels > 1:
print(str(nickels)+" nickels")
else:
print(str(nickels)+" nickel")
if not(pennies == 0):
if pennies > 1:
print(str(pennies)+" pennies")
else:
print(str(pennies)+" penny")
Explanation:
A prompt to input amount in cents
cents = int(input("Cents: "))
Convert cents to dollars
dollars = int(cents/100)
Convert the remaining cents to quarters
quarters = int((cents - 100*dollars)/25)
Convert the remaining cents to dimes
dimes = int((cents - 100*dollars- 25*quarters)/10)
Convert the remaining cents to nickels
nickels = int((cents - 100*dollars- 25*quarters-10*dimes)/5)
Convert the remaining cents to pennies
pennies = cents - 100*dollars- 25*quarters-10*dimes-5*nickels
This checks if dollars is not 0
if not(dollars == 0):
If greater than 1, it prints dollars (plural)
if dollars > 1:
print(str(dollars)+" dollars")
Otherwise, prints dollar (singular)
else:
print(str(dollars)+" dollar")
This checks if quarters is not 0
if not(quarters == 0):
If greater than 1, it prints quarters (plural)
if quarters > 1:
print(str(quarters)+" quarters")
Otherwise, prints quarter (singular)
else:
print(str(quarters)+" quarter")
This checks if dimes is not 0
if not(dimes == 0):
If greater than 1, it prints dimes (plural)
if dimes > 1:
print(str(dimes)+" dimes")
Otherwise, prints dime (singular)
else:
print(str(dimes)+" dime")
This checks if nickels is not 0
if not(nickels == 0):
If greater than 1, it prints nickels (plural)
if nickels > 1:
print(str(nickels)+" nickels")
Otherwise, prints nickel (singular)
else:
print(str(nickels)+" nickel")
This checks if pennies is not 0
if not(pennies == 0):
If greater than 1, it prints pennies (plural)
if pennies > 1:
print(str(pennies)+" pennies")
Otherwise, prints penny (singular)
else:
print(str(pennies)+" penny")
Consider this scenario: A major software company finds that code has been executed on an infected machine in its operating system. As a result, the company begins working to manage the risk and eliminates the vulnerability 12 days later. Which of the following statements best describes the company’s approach?
Answer:
The company effectively implemented patch management.
Explanation:
From the question we are informed about a scenario whereby A major software company finds that code has been executed on an infected machine in its operating system. As a result, the company begins working to manage the risk and eliminates the vulnerability 12 days later. In this case The company effectively implemented patch management. Patch management can be regarded as process involving distribution and application of updates to software. The patches helps in error correction i.e the vulnerabilities in the software. After the release of software, patch can be used to fix any vulnerability found. A patch can be regarded as code that are used in fixing vulnerabilities
Define a function roll() that takes no arguments, and returns a random integer from 1 to 6. Before proceeding further, we recommend you write a short main method to test it out and make sure it gives you the right values. Comment this main out after you are satisfied that roll() works.
Answer:
Follows are the code to this question:
#include <iostream>//defining a header file
using namespace std;
int roll()//defining a method roll
{
return 1+(rand() %5);//use return keyword that uses a rand method
}
int main()//defining main method
{
cout<<roll();//calling roll method that print is value
return 0;
}
Output:
4
Explanation:
In this code, the "roll" method is defined, that uses the rand method with the return keyword, that returns the value between 1 to 6, and in the next step, the main method is declared, that uses the print method to calls the roll method.
I need help for my computer science class I would appreciate it
Answer:
21
Explanation:
a = 7
b = 7
c = 2
7 is greater than or equal to 7 , so it will return 7 + 7 *2 which is 21
g Write a program that reads a list of words, and a character. The output of the program is every word in the list of words that contains the character at least once. For coding simplicity, follow each output word by a comma, even the last one. Assume at least one word in the list will contain the given character. The number of input words is always less than and equal to 10. If the user enters more than 10 words before the character, the program will output Too many words and exit.
Answer:
Here you go, alter this as you see fit :)
Explanation:
array = []
cnt = 0
while cnt < 11:
x = input("Enter a word: ")
array.append(x)
cnt += 1
y = input("Add another word?(Y/n): ")
if y.lower() == "n":
break
letter = input("\nChoose a letter: ")
if len(letter) != 1:
print("Error: too many characters")
quit()
for n in range(len(array)):
if letter.lower() in array[n].lower():
print(array[n], end= ",")
Create a program that writes a series of random numbers to a file, then reads the file to calculate the average of those numbers, as well as the highest and lowest numbers. Prompt the user for how many random numbers they want to add to file. If the number is less than 100, add at least 100 numbers. Each random number should be between 10 and 500, inclusive (at least 10, no more than 500). Create the file as YourName_randomnumbers.txt (where YourName is your actual name or initials...) Once the program creates the file, open and read in all numbers. Loop through the numbers and determine the highest number, the lowest number, count how many entries are in the file, and calculate the average of all numbers. Remember to use functions and comment as needed. Submit your .py file and your randomnumbers.txt file.
Answer:
In Python:
import random
def average(content):
sum = 0
for i in range(0, len(content)):
content[i] = int(content[i])
sum = sum + content[i]
print("Average: "+str(round(sum/len(content),2)))
def maxList(content):
print("Highest: "+str(max(content)))
def minList(content):
print("Lowest: "+str(min(content)))
f = open("YourName_randomnumbers.txt", "w")
num = int(input("Random Numbers: "))
if num < 100:
num = 100
for i in range(1,num+1):
f.write(str(random.randint(10,500)))
f.write(" ")
f.close()
with open('YourName_randomnumbers.txt') as ff:
content = ff.read().split()
print("Entries: "+str(len(content)))
average(content)
maxList(content)
minList(content)
Explanation:
First, we import the random module
import random
The program uses functions. The first is the average function
def average(content):
This initializes sum to 0
sum = 0
This iterates through the list and adds up the list elements
for i in range(0, len(content)):
content[i] = int(content[i])
sum = sum + content[i]
This prints the average, rounded to 2 decimal places
print("Average: "+str(round(sum/len(content),2)))
The maxList function begins here
def maxList(content):
This gets and prints the highest of the list
print("Highest: "+str(max(content)))
The minList function begins here
def minList(content):
This gets and prints the lowest of the list
print("Lowest: "+str(min(content)))
The main begins here
This createa a file and prepares it for write operations
f = open("YourName_randomnumbers.txt", "w")
This prompts user for number of random numbers
num = int(input("Random Numbers: "))
If user input is less than 100
if num < 100:
It is set to 100
num = 100
The following iteration generates random numbers between 10 and 500 and inserts the random number to file
for i in range(1,num+1):
f.write(str(random.randint(10,500)))
f.write(" ")
Close file
f.close()
The following iteration reads the file content into a list
with open('YourName_randomnumbers.txt') as ff:
content = ff.read().split()
This prints the number of entries
print("Entries: "+str(len(content)))
The next three instructions calls the average, maxList and minList functions respectively
average(content)
maxList(content)
minList(content)
Find an overall minimum two-level circuit (corresponding to sum of products expressions) using multiple AND and one multi-input OR gate per function for the following set of functions. Show a K-map for each function, and draw the final two-level circuit. You will have to share terms between F and G to find the minimum circuit.
F(a, b, c, d) = m(0, 1, 2, 3, 6, 7, 8, 10, 12, 13)
G(a, b, c, d) = {m(0, 1, 2, 3, 8, 9, 10, 13)
Answer:
si la pusiera en español te pudiera responer
Where can I watch jersey shore for free
Pls don’t say soap2day, any apps or something?
Answer:
maybe try Y o u t u b e
Explanation:
sometimes they have full episodes of shoes on there for free
what 80s Disney movie was called the movie that nearly killed Disney? P.S. look it up
Answer:
The black cauldron
Explanation:
it was the most expensive animated film of its time ever made
Answer: The Black Couldren.
Explanation:
Write a function called count_types that returns a dictionary with keys that are Pokemon types and values that are the number of times that type appears in the dataset. The order of the keys in the returned dictionary does not matter. In terms of efficiency, your solution should NOT iterate over the whole dataset once for each type of Pokemon since that would be overly inefficient. For example, assuming we have parsed pokemon_test.csv and stored it in a variable called data:
Answer:
Explanation:
The following code is written in Python. It creates a function called count_types which takes in three parameters. The pokemon in question, the data set, and a dictionary with all the pokemon types and values (Empty to start). Then it simply uses the built-in Python count feature to count the number of times that the Pokemon appears in the data set. Finally it saves that pokemon as a key and count as a value to the dictionary.
def count_types(pokemon, data, my_dict):
count = data.count(pokemon)
my_dict += {pokemon: count}
Paula weeded 40% of her garden in 8 minutes. How many minutes will it take to weed all of her garden at this rate ?
Answer:
38 minutes long
Explanation:
you would do 40% ÷ 8 to get your answer I think
Giving brainliest if you answer question.
Write a program called clump that accepts an ArrayList of strings as a parameter and replaces each pair of strings with a single string that consists of the two original strings in parentheses separated by a space. If the list is of odd length, the final element is unchanged. For example, suppose that a list contains
Answer:
In Java:
public static void clump(ArrayList<String> MyList) {
for(int i = 0; i<MyList.size()-1;i++){
String newStr = "(" + MyList.get(i) + " "+ MyList.get(i + 1) + ")";
MyList.set(i, newStr);
MyList.remove(i + 1);
}
System.out.println("Updated ArrayList: " + MyList);
}
Explanation:
First, we define the method
public static void clump(ArrayList<String> MyList) {
Next, we iterate through the ArrayList
for(int i = 0; i<MyList.size()-1;i++){
This clumps/merges every other ArrayList element
String newArr = "(" + MyList.get(i) + " "+ MyList.get(i + 1) + ")";
This updates the elements of the ArrayList
MyList.set(i, newArr);
This removes ArrayList elements at odd indices (e.g. 1,3...)
MyList.remove(i + 1);
}
This prints the updated List
System.out.println("Updated ArrayList: " + MyList);
}
Compression algorithms vary in how much they can reduce the size of a document.
Which of the following would likely be the hardest to compress?
Choose 1 answer:
A. The Declaration of Independence
B. The lyrics to all of the songs by The Beatles
C. A document of randomly generated letters
D. A book of nursery rhymes for children
The statement that represents the thing that would likely be the hardest to compress is a document of randomly generated letters. Thus, the most valid option for this question is C.
What is an Algorithm?An algorithm may be characterized as a type of methodology that is significantly utilized for solving a problem or performing a computation with respect to any numerical problems.
According to the context of this question, an algorithm is a set of instructions that allows a user to perform solutions with respect to several numerical and other program-related queries. It can significantly act as an accurate list of instructions that conduct particular actions step by step in either hardware- or software-based routines.
Therefore, the statement that represents the thing that would likely be the hardest to compress is a document of randomly generated letters. Thus, the most valid option for this question is C.
To learn more about Algorithms, refer to the link:
https://brainly.com/question/24953880
#SPJ3
A marketing plan includes a number of factors, including the marketing mix.
What is the marketing mix?
A. The variables of product, price, place, and promotion
B. Using names and symbols to ideny the company's products
C. How the company intends for customers to view its product
relative to the competition
D. A plan for spending money
SUBMIT
3. In your application, you are using a stack data structure to manipulate information. You need to find which data item will be processed next, but you don’t want to actually process that data item yet. Which of the following queue operations will you use?
a) pop
b) push
c) peek
d) contains
Answer:
I think its contains, but i would ask on stack overflow.
Explanation:
How does PowerPoint know which objects to group? The objects are aligned side by side. The objects are placed in one part of the slide. The objects are selected using the Ctrl key. The objects are highlighted and dragged together.
Answer:the objects are selected using the Ctrl key
Explanation:
Just took it
Answer: C
Explanation:
You may have come across websites that not only ask you for a username and password, but then ask you to answer pre-selected personal questions about yourself. What can you conclude about this procedure and how it may increase your security?
Answer:
The questions are used to secure and identify you furthermore. Answering personal questions that only you can answer will deter someone from hacking into your account that easily.
Explanation:
Please help ASAP!
A career can include classes, experiences, jobs, and:
A. fields.
B. training.
C. regions.
D. laws.
Robert has opened his own pet supply store so he can help himself to treats and toys whenever he wishes. In order to encourage customers to shop at his store more, he is implementing a customer loyalty program. For every $100 spent, the customer earns a 10% discount on a future purchase. If the customer has earned a discount, that discount will be automatically applied whenever they make a purchase. Only one discount can be applied per purchase. Implement a class Customer that represents a customer in Robert's store.
Answer:
Explanation:
The following code is written in Python and creates a class called customer which holds the customers name, purchase history amount, and current total. It also has 3 functions, a constructor that takes the customer name as a parameter. The add_to_cart function which increases the amount of the current total. And finally the checkout function which applies the available coupon and resets the variables if needed, as well as prints the info the to screen.
class Customer():
customer = ""
purchased_history = 0
current_total = 0
def __init__(self, name):
self.customer = name
def add_to_cart(self, amount):
self.current_total += amount
def checkout(self):
if self.purchased_history >= 100:
self.current_total *= 0.90
self.purchased_history = 0
else:
self.purchased_history += self.current_total
print(self.customer + " current total is: $" + str(self.current_total))
self.current_total = 0
String[][] arr = {{"Hello,", "Hi,", "Hey,"}, {"it's", "it is", "it really is"}, {"nice", "great", "a pleasure"},
{"to", "to get to", "to finally"}, {"meet", "see", "catch up with"},
{"you", "you again", "you all"}};
for (int j = 0; j < arr.length; j++) {
for (int k = 0; k < arr[0].length; k++) {
if (k == 1) { System.out.print(arr[j][k] + " ");
}
}
}
What, if anything, is printed when the code segment is executed?
Answer:
Explanation:
The code that will be printed would be the following...
Hi, it is great to get to see you again
This is mainly due to the argument (k==1), this argument is basically stating that it will run the code to print out the value of second element in each array within the arr array. Therefore, it printed out the second element within each sub array to get the above sentence.
When the code segment is executed, the output is "Hi, it is great to get to see you again "
In the code segment, we have the following loop statements
for (int j = 0; j < arr.length; j++) {for (int k = 0; k < arr[0].length; k++) {The first loop iterates through all elements in the array
The second loop also iterates through all the elements of the array.
However, the if statement ensures that only the elements in index 1 are printed, followed by a space
The elements at index 1 are:
"Hi," "it" "is" "great" "to" "get" "to" "see" "you" "again"
Hence, the output of the code segments is "Hi, it is great to get to see you again "
Read more about loops and conditional statements at:
https://brainly.com/question/26098908
What styles can the calendar be printed in? Check all that apply.
Quick
Daily style
Weekly Agenda style
Weekly Calendar style
Monthly Agenda style
Monthly style
Bifold style
Trifold style
Answer:
Daily style
Weekly Agenda style
Weekly Calendar style
Monthly style
Trifold style
or
B, C, D, F, H
When using the Mirror command you can delete the source object as the last step of the command. True or false
Answer:
The anwser is true it is true.
Define the _make method, which takes one iterable argument (and no self argument: the purpose of _make is to make a new object; see how it is called below); it returns a new object whose fields (in the order they were specified) are bound to the values in the interable (in that same order). For example, if we called Point._make((0,1)) the result returned is a new Point object whose x attribute is bound to 0 and whose y attribute is bound to 1.
We can actually see that the _make method is known to be a function that creates named tuple type.
What is _make method?_make method is seen in Python programming which is used to create a named tuple type instantly. It can be used for conversion of objects e.gtuple, list, etc. to named tuple.
Thus, we see the definition of _make method.
Learn more about Python on https://brainly.com/question/26497128
#SPJ2
Write the Number class that can be used to test if the number is odd, even, and perfect. A perfect number is any number that is equal to the sum of its divisors. Write the NumberAnalyzer class that has an ArrayList of Number to determine how many numbers in the list are odd, even, and perfect.
Answer:
Explanation:
The following code is written in Python. It creates a class that takes in one ArrayList parameter and loops through it and calls two functions that check if the numbers are Perfect, Odd, or Even. Then it goes counting each and printing the final results to the screen.
class NumberAnalyzer:
def __init__(self, myArray):
perfect = 0
odd = 0
even = 0
for element in myArray:
if self.isPerfect(element) == True:
perfect += 1
else:
if self.isEven(element) == True:
even += 1
else:
odd += 1
print("# of Perfect elements: " + str(perfect))
print("# of Even elements: " + str(even))
print("# of Odd elements: " + str(odd))
def isPerfect(self, number):
sum = 1
i = 2
while i * i <= number:
if number % i == 0:
sum = sum + i + number / i
i += 1
if number == sum:
return True
else:
return False
def isEven(self, number):
if (number % 2) == 0:
return True
else:
return False
Which term refers to a solution to a large problem that is based on the solutions of smaller subproblems. A. procedural abstraction B. API C. modularity D. library
Answer:
procedural abstraction
Explanation:
The term that refers to a solution to a large problem that is based on the solutions of smaller subproblems is A. procedural abstraction.
Procedural abstraction simply means writing code sections that are generalized by having variable parameters.
Procedural abstraction is essential as it allows us to think about a framework and postpone details for later. It's a solution to a large problem that is based on the solutions of smaller subproblems.
Read related link on:
https://brainly.com/question/12908738
A car dealership needs a program to store information about the cars for sale. For each car, they want to keep track of the following information number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon. Which of the following is the best design?
a. Use classes: Doors, Airconditioning, and MilesPerGallon, each with a subclass Car.
b. Use a class Car, with subclasses of Doors, Airconditioning, and MilesPerGallon.
c. Use a class Car with three subclasses: Doors, Airconditioning, and MilesPerGallon.
d. Use a class Car, with fields: numDoors, hasAir, and milesPerGallon.
e. Use four unrelated classes: Car, Doors, Airconditioning, and MilesPerGallon.
Answer:
The answer is "Choice d".
Explanation:
In this topic, the option d, which is "Use a class Car, with fields: numDoors, hasAir, and milesPerGallon" is right because the flag, if air-conditioned, of its numbers of doors, was its average kilometers per gallon, qualities of either an automobile, in which each one is a basic value so that they're being fields of a class of cars.
The best design for the given program will be;
D: Use a class Car, with fields: numDoors, hasAir, and milesPerGallon.
What is the best design for the program?In this question, the best design for the program to keep track of the number of doors (2 or 4), whether the car has air conditioning, and its average number of miles per gallon is to "Use a class Car, with fields: numDoors, hasAir, and milesPerGallon"
That option is right because has classified the cars with the accurate parameters to be searched which are its numbers of doors, average miles per gallon, air condition.
Read more about programming at; https://brainly.com/question/22654163
Play now? Play later?
You can become a millionaire! That's what the junk mail said. But then there was the fine print:
If you send in your entry before midnight tonight, then here are your chances:
0.1% that you win $1,000,000
75% that you win nothing
Otherwise, you must PAY $1,000
But wait, there's more! If you don't win the million AND you don't have to pay on your first attempt,
then you can choose to play one more time. If you choose to play again, then here are your chances:
2% that you win $100,000
20% that you win $500
Otherwise, you must PAY $2,000
What is your expected outcome for attempting this venture? Solve this problem using
a decision tree and clearly show all calculations and the expected monetary value at each node.
Use maximization of expected value as your decision criterion.
Answer these questions:
1) Should you play at all? (5%) If you play, what is your expected (net) monetary value? (15%)
2) If you play and don't win at all on the first try (but don't lose money), should you try again? (5%) Why? (10%)
3) Clearly show the decision tree (40%) and expected net monetary value at each node (25%)
Answer:
wow what a scam
Explanation: