Answer:
Explanation:
The following code is written in Python and creates arrays for the user's numbers and the next chance numbers, it also creates a cost variable and a did_you_win variable. The function takes in the winning numbers as an array parameter. It asks all the necessary questions to generate data for all the variables and then compares the user's numbers to the winning numbers in order to detect if the user has won. Finally, it prints all the necessary information.
import random
def lottery(winning_numbers):
user_numbers = []
next_chance_drawing = []
cost = 0
did_you_win = "No"
#print("Would you like to choose your own 5 numbers? Y or N")
answer = input("Would you like to choose your own 5 numbers? Y or N: ")
if answer.capitalize() == "Y":
for x in range(5):
user_numbers.append(input("Enter number " + str(x+1) + ": "))
else:
for x in range(5):
user_numbers.append(random.randint(0,31))
cost += 1
next_chance = input("Would you like to enter a Next Chance drawing for $1.00? Y or N: ")
if next_chance.capitalize() == "Y":
for x in range(4):
next_chance_drawing.append(random.randint(0, 31))
cost += 1
if user_numbers == winning_numbers or next_chance_drawing == winning_numbers:
did_you_win = "Yes"
print("User Numbers: " + str(user_numbers))
print("Next Chance Numbers: " + str(next_chance_drawing))
print("Cost: $" + str(cost))
print("Did you win: " + did_you_win)
Python (and most programming languages) start counting with 0.
True
False
Answer:
yes its true :)
Explanation:
You've created a new programming language, and now you've decided to add hashmap support to it. Actually you are quite disappointed that in common programming languages it's impossible to add a number to all hashmap keys, or all its values. So you've decided to take matters into your own hands and implement your own hashmap in your new language that has the following operations:
insert x y - insert an object with key x and value y.
get x - return the value of an object with key x.
addToKey x - add x to all keys in map.
addToValue y - add y to all values in map.
To test out your new hashmap, you have a list of queries in the form of two arrays: queryTypes contains the names of the methods to be called (eg: insert, get, etc), and queries contains the arguments for those methods (the x and y values).
Your task is to implement this hashmap, apply the given queries, and to find the sum of all the results for get operations.
Example
For queryType = ["insert", "insert", "addToValue", "addToKey", "get"] and query = [[1, 2], [2, 3], [2], [1], [3]], the output should be hashMap(queryType, query) = 5.
The hashmap looks like this after each query:
1 query: {1: 2}
2 query: {1: 2, 2: 3}
3 query: {1: 4, 2: 5}
4 query: {2: 4, 3: 5}
5 query: answer is 5
The result of the last get query for 3 is 5 in the resulting hashmap.
For queryType = ["insert", "addToValue", "get", "insert", "addToKey", "addToValue", "get"] and query = [[1, 2], [2], [1], [2, 3], [1], [-1], [3]], the output should be hashMap(queryType, query) = 6.
The hashmap looks like this after each query:
1 query: {1: 2}
2 query: {1: 4}
3 query: answer is 4
4 query: {1: 4, 2: 3}
5 query: {2: 4, 3: 3}
6 query: {2: 3, 3: 2}
7 query: answer is 2
The sum of the results for all the get queries is equal to 4 + 2 = 6.
Input/Output
[execution time limit] 4 seconds (py3)
[input] array.string queryType
Array of query types. It is guaranteed that each queryType[i] is either "addToKey", "addToValue", "get", or "insert".
Guaranteed constraints:
1 ≤ queryType.length ≤ 105.
[input] array.array.integer query
Array of queries, where each query is represented either by two numbers for insert query or by one number for other queries. It is guaranteed that during all queries all keys and values are in the range [-109, 109].
Guaranteed constraints:
query.length = queryType.length,
1 ≤ query[i].length ≤ 2.
[output] integer64
The sum of the results for all get queries.
[Python3] Syntax Tips
# Prints help message to the console
# Returns a string
def helloWorld(name):
print("This prints to the console when you Run Tests")
return "Hello, " + name
Answer:
Attached please find my solution in JAVA
Explanation:
long hashMap(String[] queryType, int[][] query) {
long sum = 0;
Integer currKey = 0;
Integer currValue = 0;
Map<Integer, Integer> values = new HashMap<>();
for (int i = 0; i < queryType.length; i++) {
String currQuery = queryType[i];
switch (currQuery) {
case "insert":
HashMap<Integer, Integer> copiedValues = new HashMap<>();
if (currKey != 0 || currValue != 0) {
Set<Integer> keys = values.keySet();
for (Integer key : keys) {
copiedValues.put(key + currKey, values.get(key) + currValue);
}
values.clear();
values.putAll(copiedValues);
currValue = 0;
currKey = 0;
}
values.put(query[i][0], query[i][1]);
break;
case "addToValue":
currValue += values.isEmpty() ? 0 : query[i][0];
break;
case "addToKey":
currKey += values.isEmpty() ? 0 : query[i][0];
break;
case "get":
copiedValues = new HashMap<>();
if (currKey != 0 || currValue != 0) {
Set<Integer> keys = values.keySet();
for (Integer key : keys) {
copiedValues.put(key + currKey, values.get(key) + currValue);
}
values.clear();
values.putAll(copiedValues);
currValue = 0;
currKey = 0;
}
sum += values.get(query[i][0]);
}
}
return sum;
}
What is the difference of using Selection Tool and Direct Selection Tool?
Answer:
The Selection tool will always select the object as a whole. Use this tool when you want to manipulate the entire object. The Direct Selection tool will always select the points or segments that make up a frame
Explanation:
Approximately how many numeric IP addresses are possible with IPv4?
4 billon
Answer:
4,294,967,296 (~4.3B)
Explanation:
IPv4 uses 32-bits for representing addresses, thus you can have 2^32 total combinations.
let m be a positive integer with n bit binary representation an-1 an-2 ... a1a0 with an-1=1 what are the smallest and largest values that m could have
Answer:
Explanation:
From the given information:
[tex]a_{n-1} , a_{n-2}...a_o[/tex] in binary is:
[tex]a_{n-1}\times 2^{n-1} + a_{n-2}}\times 2^{n-2}+ ...+a_o[/tex]
So, the largest number posses all [tex]a_{n-1} , a_{n-2}...a_o[/tex] nonzero, however, the smallest number has [tex]a_{n-2} , a_{n-3}...a_o[/tex] all zero.
∴
The largest = 11111. . .1 in n times and the smallest = 1000. . .0 in n -1 times
i.e.
[tex](11111111...1)_2 = ( 1 \times 2^{n-1} + 1\times 2^{n-2} + ... + 1 )_{10}[/tex]
[tex]= \dfrac{1(2^n-1)}{2-1}[/tex]
[tex]\mathbf{=2^n -1}[/tex]
[tex](1000...0)_2 = (1 \times 2^{n-1} + 0 \times 2^{n-2} + 0 \times 2^{n-3} + ... + 0)_{10}[/tex]
[tex]\mathbf {= 2 ^{n-1}}[/tex]
Hence, the smallest value is [tex]\mathbf{2^{n-1}}[/tex] and the largest value is [tex]\mathbf{2^{n}-1}[/tex]
5. All sites are required to have the following reference materials available for use at VITA/TCE sites in paper or electronic format: Publication 17, Publication 4012, Volunteer Tax Alerts (VTA), and Quality Site Requirement Alerts (QSRA). AARP Foundation Tax Aide uses CyberTax Alerts in lieu of VTAs and QSRAs. What other publication must be available at each site and contains information about the new security requirements at sites
Answer:
Publication 5140.
Explanation:
The acronym VITA stands for Volunteer Income Tax Assistance and TCE stands for Tax Counseling for the Elderly. VITA/TCE is a certification gotten from the Internal Revenue Service in which the holders of such certification are trained on how to help people that have disabilities or that their incomes earners that are low. These volunteers help these set of people to prepare for their tax return.
In order to make the volunteers to be able to perform their work with high accuracy, the Department of Treasury, Internal Revenue Service gave out some aids for Quality Site. One of the aids which is the one contains information about the new security requirements at sites is given in the Publication 5140.
Help need right now pls
Read the following Python code:
yards - 26
hexadecimalYards = hex (yards)
print (hexadecimalYards)
Which of the following is the correct output? (5 points)
A. 0b1a
B. 0d1a
C. 0h1a
D. 0x1a
Answer:
d. 0x1a
Explanation:
Drag the tiles to the correct boxes to complete the pairs.
Match each type of database to its application
Multistage
Stationary
Distributed
Virtual
used for concise as well as detailed
historical data
arrowRight
used where access to data is rare
arrowRight
used for accessing data in diverse
applications using middleware
arrowRight
used by an organization that runs
several businesses
arrowRight
Answer:
1. Multistage database.
2. Stationary database.
3. Virtual database.
4. Distributed database.
Explanation:
A database management system (DBMS) can be defined as a collection of software applications that typically enables computer users to create, store, modify, retrieve and manage data or informations in a database. Generally, it allows computer users to efficiently retrieve and manage their data with an appropriate level of security.
There are four (4) major types of database in a data warehouse and these are;
1. Multistage database: used for concise as well as detailed historical data. It provides summarized data which can be used by an employee for short-term decision making.
2. Stationary database: used where access to data is rare i.e business firms who do not access data frequently. In order to use this database, the users must have an access to metadata store and thus, directly having access to the data on a source system.
3. Virtual database: used for accessing data in diverse applications using middleware. This type of database is dependent on having access to information on various databases.
4. Distributed database: used by an organization that runs several businesses. Therefore, this type of database are usually located or situated in various geographical regions.
Write a program that will perform a few different String operations. The program must prompt for a name, and then tell the user how many letters are in the name, what the first letter of the name is, and what the last letter of the name is. It should then end with a goodbye message. A sample transcript of what your program should do is below:
Enter your name: Jeremy
Hello Jeremy!
Your name is 6 letters long.
Your name starts with a J.
Your name ends with a y.
Goodbye!
Answer:
Follows are the code to this question:
import java.util.*;//import package for user input
public class Main//defining a class Main
{
public static void main(String[] asp)//main method
{
String n;//defining String variable
Scanner oxr=new Scanner(System.in);//creating Scanner class Object
System.out.print("Enter your name: ");//print message
n=oxr.next();//input value
System.out.println("Hello "+n+"!");//print message with value
System.out.println("Your name is "+n.length()+" letters long.");//print message with value
System.out.println("Your name starts with a "+n.charAt(0)+".");//print message with value
System.out.println("Your name ends with a "+n.charAt(n.length()-1)+".");//print message with value
System.out.print("Goodbye!");//print message
}
}
Output:
Please find the attached file.
Explanation:
In the above-given code, A string variable "n" is declared, that uses the Scanner class object for input the value from the user-end.
In the next step, the multiple print method has used, which calculates the length, first and the last latter of the string value, and uses the print method to print the calculated value with the given message.
A structure that organizes data in a list that is commonly 1-dimensional or 2-
dimensional
Linear Section
Constant
No answertet provided
It intro technology
Answer:
An array.
Explanation:
An array can be defined as a structure that organizes data in a list that is commonly 1-dimensional or 2-dimensional.
Simply stated, an array refers to a set of memory locations (data structure) that comprises of a group of elements with each memory location sharing the same name. Therefore, the elements contained in array are all of the same data type e.g strings or integers.
Basically, in computer programming, arrays are typically used by software developers to organize data, in order to search or sort them.
Binary search is an efficient algorithm used to find an item from a sorted list of items by using the run-time complexity of Ο(log n), where n is total number of elements. Binary search applies the principles of divide and conquer.
In order to do a binary search on an array, the array must first be sorted in an ascending order.
Hence, array elements are mainly stored in contiguous memory locations on computer.
developed the first compiler and conducted work that led to the development of COBOL ?
Answer:
Grace Hopper.
Explanation:
Grace Hopper was a US Naval Rear Admiral and an American computer scientist who was born on the 9th of December, 1906 in New York city, United States of America. She worked on the first commercial computer known as universal automatic computer (UNIVAC), after the second World War II.
In 1953 at the Remington Rand, Grace Hopper invented the first high-level programming language for UNIVAC 1 by using words and expressions.
Additionally, the high-level programming language known as FLOW-MATIC that she invented in 1953 paved the way for the development of common business-oriented language (COBOL).
Hence, Grace Hopper developed the first compiler and conducted work that led to the development of COBOL.
Implement the method countInitial which accepts as parameters an ArrayList of Strings and a letter, stored in a String. (Precondition: the String letter has only one character. You do not need to check for this.) The method should return the number of Strings in the input ArrayList that start with the given letter. Your implementation should ignore the case of the Strings in the ArrayList. Hint - the algorithm to implement this method is just a modified version of the linear search algorithm. Use the runner class to test your method but do not add a main method to your U7_L4_Activity_One.java file or your code will not be scored correctly.
Answer:
Answered below
Explanation:
//Program is implemented in Java
public int countInitials(ArrayList<string> words, char letter){
int count = 0;
int i;
for(i = 0; i < words.length; i++){
if ( words[i][0]) == letter){
count++
}
}
return count;
}
//Test class
Class Test{
public static void main (String args[]){
ArrayList<string> words = new ArrayList<string>()
words.add("boy");
words.add("bell");
words.add("cat");
char letter = 'y';
int numWords = countInitials ( words, letter);
System.out.print(numWords);
}
}
instructions and programs data are stored in the same memory in which concept
Answer:
The term Stored Program Control Concept refers to the storage of instructions in computer memory to enable it to perform a variety of tasks in sequence or intermittently.
You are a computer consultant called in to a manufacturing plant. The plant engineer needs a system to control their assembly line that includes robotic arms and conveyors. Many sensors are used and precise timing is required to manufacture the product. Of the following choices, which OS would you recommend to be used on the computing system that controls the assembly line and why
Answer:
Linux operating system is suitable for the operation of the automated system because it is more secure with a free open-source codebase to acquire and create new applications on the platform.
Explanation:
Linux operating system is open-source software for managing the applications and network functionalities of a computer system and its networks. It has a general public license and its code is available to users to upgrade and share with other users.
The OS allows user to configure their system however they chose to and provides a sense of security based on user privacy.
Given that the variable named Boy = "Joey" and the variable named Age = 6, create statements that will output the following message:
Congratulations, Joey! Today you are 6 years old.
First, write one statement that will use a variable named Message to store the message. (You will need to concatenate all of the strings and variables together into the one variable named Message. If you don't know what that means, read the section in Chapter 1 about concatenation.)
Then write a second statement that will simply output the Message variable.
Answer:
isn't it already showing it if not put text box
Explanation:
Last one, this is fashion marketing and I need to know the answer to get the 80%
Answer:
D. It requires that each item of stock is counted and recorded to determine stock levels
Explanation:
A perpetual system of inventory can be defined as a method of financial accounting, which involves the updating informations about an inventory on a continuous basis (in real-time) as the sales or purchases are being made by the customers, through the use of enterprise management software applications and a digitized point-of-sale (POS) equipment.
Under a perpetual system of inventory, updates of the journal entry for cost of goods sold or received would include debiting accounts receivable and crediting sales immediately as it is being made or happening.
Hence, an advantage of the perpetual system of inventory over the periodic system of inventory is that, it ensures the inventory account balance is always accurate provided there are no spoilage, theft etc.
The following are the characteristic of a perpetual inventory system;
I. It is the most popular choice for modern business.
II. Inventory is updated in near real-time.
III. It provides up-to-date balance information and requires fewer physical counts.
In CengageNOWv2, you may move, re-size, and rearrange panels in those assignments that use multiple panels.
Answer:
true
Explanation:
trust me lol, I promise it's correct.