A. Schedule Update for Project XYZ
Answer:
Schedule Update for Project XYZ
Explanation:
Emerging technology is exciting because it can bounce back and forth between which two worlds?
Can anyone described the purpose of this algorithm
GuessCorrect ← FALSE
INPUT Player1Num
WHILE GuessCorrect <> TRUE
INPUT Player2 Guess
IF Player1Num = Player2 Guess
Then
OUTPUT "Your guess is correct"
GuessCorrect ← True
ELSE
IF Player1Num > Player2Guess
THEN
OUTPUT "Too high"
ELSE
OUTPUT "Too low"
Can anyone describe the purpose of this algorithm?
This algorithm is a simple guessing game designed to be played between two players. The purpose of this algorithm is to allow Player 2 to guess a number, and to output whether their guess is too high or too low, until they guess the correct number.
The algorithm first prompts Player 1 to input a number, which will be the number that Player 2 needs to guess. Then, the algorithm enters a loop, where it repeatedly prompts Player 2 to input a guess. If the guess is equal to the number that Player 1 inputted, the algorithm outputs "Your guess is correct" and exits the loop. Otherwise, the algorithm outputs "Too high" or "Too low", depending on whether the guess is higher or lower than the target number, and continues the loop.
The loop continues until the correct number is guessed, at which point the algorithm sets the value of GuessCorrect to TRUE, which allows the loop to exit.
This algorithm is a basic example of a while loop in programming, and it demonstrates how loops can be used to repeatedly execute a set of instructions until a specific condition is met. It can be used as a starting point for more complex games or simulations that require the use of loops and conditions to execute specific tasks or behaviors.
~ Zeph
Explanation:
honestly I'm not into computer but I promise that I coming back to give you the answer
The total number of AC cycles completed in one second is the current’s A.timing B.phase
C.frequency
D. Alterations
The total number of AC cycles completed in one second is referred to as the current's frequency. Therefore, the correct answer is frequency. (option c)
Define AC current: Explain that AC (alternating current) is a type of electrical current in which the direction of the electric charge periodically changes, oscillating back and forth.
Understand cycles: Describe that a cycle represents one complete oscillation of the AC waveform, starting from zero, reaching a positive peak, returning to zero, and then reaching a negative peak.
Introduce frequency: Define frequency as the measurement of how often a cycle is completed in a given time period, specifically, the number of cycles completed in one second.
Unit of measurement: Explain that the unit of measurement for frequency is hertz (Hz), named after Heinrich Hertz, a German physicist. One hertz represents one cycle per second.
Relate frequency to AC current: Clarify that the total number of AC cycles completed in one second is directly related to the frequency of the AC current.
Importance of frequency: Discuss the significance of frequency in electrical engineering and power systems. Mention that it affects the behavior of electrical devices, the design of power transmission systems, and the synchronization of different AC sources.
Frequency measurement: Explain that specialized instruments like frequency meters or digital multimeters with frequency measurement capabilities are used to accurately measure the frequency of an AC current.
Emphasize the correct answer: Reiterate that the current's frequency represents the total number of AC cycles completed in one second and is the appropriate choice from the given options.
By understanding the relationship between AC cycles and frequency, we can recognize that the total number of AC cycles completed in one second is referred to as the current's frequency. This knowledge is crucial for various aspects of electrical engineering and power systems. Therefore, the correct answer is frequency. (option c)
For more such questions on AC cycles, click on:
https://brainly.com/question/15850980
#SPJ8
What is the benefit of time boxing the preparation for the first program increment planning event
The benefit of timeboxing for the preparation for the first program increment planning event is that it seeks to deliver incremental value in the form of working such that the building and validating of a full system.
What is timeboxing?Timeboxing may be defined as a simple process of the time management technique that significantly involves allotting a fixed, maximum unit of time for an activity in advance, and then completing the activity within that time frame.
The technique of timeboxing ensures increments with the corresponding value demonstrations as well as getting prompt feedback. It allocates a fixed and maximum unit of time to an activity, called a timebox, within which planned activity takes place.
Therefore, timeboxing seeks the delivery of incremental value in the form of working such that the building and validating of a full system.
To learn more about Timeboxing, refer to the link:
https://brainly.com/question/29508600
#SPJ9
Systems study involves which of the following option ?
a.
Design of system
b.
Determination of system requirements
c.
System testing
d.
All of the options
d. All of the options are involved in systems study:
a. Design of system: This involves creating a plan or blueprint for how the system will be constructed, including its components, processes, and interactions.
b. Determination of system requirements: This involves identifying the needs and constraints of the system, including the functional and non-functional requirements, as well as any legal or ethical considerations.
c. System testing: This involves evaluating the system to ensure that it meets the requirements and functions correctly, including performance testing, security testing, and usability testing.
All of these options are critical to a comprehensive systems study, as they help ensure that the system is designed, built, and tested to meet the needs and expectations of its users.
1. Write a Java application that:
a. asks the user for the daily sales for each day of a week using a repetition loop and calculates its total.
b. calculates the average daily sales for the week
c. displays the total and average sales for the week.
Each of the three components of the program should be handled by a different method.
Here is a Java application that asks the user for the daily sales for each day of a week using a repetition loop and calculates its total, calculates the average daily sales for the week, and displays the total and average sales for the week.
The Programimport java.util.Scanner;
public class WeeklySales {
public static void main(String[] args) {
double[] sales = getDailySales();
double totalSales = calculateTotalSales(sales);
double averageSales = calculateAverageSales(sales);
displaySales(totalSales, averageSales);
}
public static double[] getDailySales() {
Scanner scanner = new Scanner(System.in);
double[] sales = new double[7];
for (int i = 0; i < 7; i++) {
System.out.print("Enter the daily sales for day " + (i+1) + ": ");
sales[i] = scanner.nextDouble();
}
scanner.close();
return sales;
}
public static double calculateTotalSales(double[] sales) {
double totalSales = 0;
for (int i = 0; i < sales.length; i++) {
totalSales += sales[i];
}
return totalSales;
}
public static double calculateAverageSales(double[] sales) {
double totalSales = calculateTotalSales(sales);
double averageSales = totalSales / sales.length;
return averageSales;
}
public static void displaySales(double totalSales, double averageSales) {
System.out.println("Total sales for the week: " + totalSales);
System.out.println("Average daily sales for the week: " + averageSales);
}
}
The getDailySales() method asks the user for the daily sales for each day of the week using a for loop and stores them in an array of doubles. It returns the array.
The calculateTotalSales(double[] sales) method calculates the total sales for the week by adding up all the daily sales in the array. It returns the total sales as a double.
The calculateAverageSales(double[] sales) method calculates the average daily sales for the week by dividing the total sales by the number of days (i.e., the length of the array). It returns the average sales as a double.
The displaySales(double totalSales, double averageSales) method displays the total and average sales for the week to the user using the println() method.
Read more about java program here:
https://brainly.com/question/26789430
#SPJ1
which of the following is a personal benifit of earning a college degree?
A) you have more friends
B) you are more likely to exercise
C) you are more likely to vote for the right candidate.
D) you have a longer life expectancy
Answer:
you have a longer life expectancy
Explanation:
Three friends decide to rent an apartment and split the cost evenly. They each paid $640 towards the total move in cost of first and last month's rent and a security deposit. If rent is $650 per month, how much was the security deposit?
a.
$10
b.
$207
c.
$620
d.
$1,270
Please select the best answer from the choices provided
Answer:
c. $620
Explanation:
To find the cost of the security deposit, we need to subtract the amount paid towards the first and last month's rent from the total move-in cost.
Each friend paid $640 towards the total move-in cost, which includes the first and last month's rent and the security deposit. Since they split the cost evenly, the total move-in cost is 3 times $640, which is $1920.
The monthly rent is $650 per month, so the first and last month's rent combined is 2 times $650, which is $1300.
To find the security deposit, we subtract the first and last month's rent from the total move-in cost:
Security deposit = Total move-in cost - First and last month's rent
Security deposit = $1920 - $1300
Security deposit = $620
Therefore, the security deposit was $620.
Option c. $620 is the correct answer.
In order to average together values that match two different conditions in different ranges, an excel user should use the ____ function.
Answer: Excel Average functions
Explanation: it gets the work done.
Answer:
excel average
Explanation:
Activity
Online security is a major issue for internet users. Threats may affect your data and applications (both online and offline), or infect your system and use up system resources.
Part A
Check your email account. Check if your email provider has a spam filter. Don’t open the email messages, but determine as much information as you can from the subject lines. Does it contain any emails that you can identify as spam? What kind of emails are they? Do they have anything in common?
Unwanted emails known as spam are distributed to several recipients in bulk. They frequently include false information, including promotions for goods or services that seem too good to be true.
Is sending bulk, unsolicited emails that you haven't requested considered spamming?Spam is any sort of bulk, unsolicited communication (Unsolicited Bulk Email, or UBE). A business email sent to many addresses is the most common form (Unsolicited Commercial Email, or UCE)
Unsolicited bulk email means that the recipient did not consent to receiving it.Unsolicited bulk email is referred to as "Spam" when used in reference to email. Unsolicited signifies that the recipient has not given the communication their explicit consent.
To know more about emails visit:-
https://brainly.com/question/14666241
#SPJ1
Select the correct text in the passage.
Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting?
Mr. Crowell has been teaching in a school for years with the help of traditional teaching methods. Recently, the school authorities have
recommended the use of computer programs and applications to facilitate a better learning experience for their students. Mr. Crowell wants to make
the classroom learning stimulating and interesting. He will have to use a few of the several computer applications available to him. These applications
include email, multimedia presentations, spreadsheets, word processing software] videos, and simulations,
rights reserved.
Reset
Next
The computer applications can Mr. Crowell use to make classroom learning more stimulating and interesting are:
b) Multimedia presentationsc) Spreadsheetsd) Word processing softwaref) SimulationsWhat are computer applications?Email, spreadsheets, and word processing software would not be good choices for him to utilize in his class as his pupils cannot interact with these tools. His major objective is to provide a better learning experience.
Mr. Crowell should think about adding multimedia presentations, movies, and simulations to augment his current teaching techniques since he wants to add more interesting computer applications to his classroom.
Therefore, the correct options are b, c, d, and f.
To learn more about computer applications, refer to the link:
https://brainly.com/question/8224724
#SPJ9
The question is incomplete. The missing options are given below:
Options:
-multimedia presentations
-spreadsheets
-word processing software
-videos
-simulation
Declare a 4 x 5 array called N.
Using for loops, build a 2D array that is 4 x 5. The array should have the following values in each row and column as shown in the output below:
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Write a subprogram called printlt to print the values in N. This subprogram should take one parameter, an array, and print the values in the format shown in the output above.
Call the subprogram to print the current values in the array (pass the array N in the function call).
Use another set of for loops to replace the current values in array N so that they reflect the new output below. Call the subprogram again to print the current values in the array, again passing the array in the function call.
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 4 4 4 4
I really need help with this thanks. (In Python)
Answer:
N = [1,1,1,1,1],
[2,2,2,2,2],
[3,3,3,3,3],
[4,4,4,4,4]
def printIt(ar):
for row in range(len(ar)):
for col in range(len(ar[0])):
print(ar[row][col], end=" ")
print("")
N=[]
for r in range(4):
N.append([])
for r in range(len(N)):
value=1
for c in range(5):
N[r].append(value)
value=value + 1
printIt(N)
print("")
newValue=1
for r in range (len(N)):
for c in range(len(N[0])):
N[r][c] = newValue
newValue = newValue + 1
printIt(N)
Explanation:
:D
Below is the required program of Python.
PythonProgram:
# Array name will be "N".
# Start program
# Defining a function and taking input array
def printIt(ar):
# Using for loop to scan the rows as well as columns of array
for row in range(len(ar)):
for col in range(len(ar[0])):
# Printing the element of array
print(ar[row][col], end=" ")
print("")
# Passing the array N
N=[]
# Again using the loop
for r in range(4):
N.append([])
# Loop to control rows
for r in range(len(N)):
value=1
# Loop to control columns
for c in range(5):
N[r].append(value)
value=value + 1
# Calling the function
printIt(N)
print("")
newValue=1
# Value in row and column
for r in range (len(N)):
for c in range(len(N[0])):
# Assigning the values to the array
N[r][c] = newValue
newValue = newValue + 1
# Printing the array
# End program
printIt(N)
Program code:
Start a program.Defining a function and taking input arrayUsing for loop to scan the rows as well as columns of arrayPrinting the element of arrayAgain using the loop to control rows and columns.Assigning the values to the arrayEnd program.Output:
Find below the attachment of the output of the program code.
Find out more information about Python here:
https://brainly.com/question/26497128
how to mitigate a DDos attack
WHAT IS DDOS MITIGATION?
DDoS mitigation refers to the process of successfully protecting a targeted server or network from a distributed denial-of-service (DDoS) attack. By utilizing specially designed network equipment or a cloud-based protection service, a targeted victim is able to mitigate the incoming threat.
There are 4 stages of mitigating a DDoS attack using a cloud-based provider:
Detection - in order to stop a distributed attack, a website needs to be able to distinguish an attack from a high volume of normal traffic. If a product release or other announcement has a website swamped with legitimate new visitors, the last thing the site wants to do is throttle them or otherwise stop them from viewing the content of the website. IP reputation, common attack patterns, and previous data assist in proper detection.
Response - in this step, the DDoS protection network responds to an incoming identified threat by intelligently dropping malicious bot traffic, and absorbing the rest of the traffic. Using WAF page rules for application layer (L7) attacks, or another filtration process to handle lower level (L3/L4) attacks such as memcached or NTP amplification, a network is able to mitigate the attempt at disruption.
Routing - By intelligently routing traffic, an effective DDoS mitigation solution will break the remaining traffic into manageable chunks preventing denial-of-service.
Adaptation - A good network analyzes traffic for patterns such as repeating offending IP blocks, particular attacks coming from certain countries, or particular protocols being used improperly. By adapting to attack patterns, a protection service can harden itself against future attacks.
Choosing a DDoS mitigation service
Traditional DDoS mitigation solutions involved purchasing equipment that would live on site and filter incoming traffic. This approach involves purchasing and maintaining expensive equipment, and also relied on having a network capable of absorbing an attack. If a DDoS attack is large enough, it can take out the network infrastructure upstream preventing any on-site solution from being effective. When purchasing a cloud-based DDoS mitigation service, certain characteristics should be evaluated.
What is the correct formula for the IF function in excel
Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")
The IF function in Microsoft Excel is the most common function in Excel that allows comparing the data.
The IF function can have two statements that is positive and negative. Like of IF(C2='' Yes'', 1, 2). Which means of c2 is yes then return one or two. Thus IF formula is used to evaluate errors.Learn more about the correct formula for the IF function in excel.
brainly.in/question/5667072.
What are the core steps to add revisions or features to a project?(1 point)
Responses
Evaluate feasibility of the goals, create a list of functionality requirements, and develop the requirements of the feature.
Evaluate feasibility of the goals, develop programming solutions, and evaluate how well the solutions address the goals.
understand the goals, evaluate the impact on the project, create a list of functionality requirements, and develop the requirements of the feature.
Communicate with the client, create a sprint backlog, develop the project, and evaluate how well the solution fits the requirements.
The core steps to add revisions or features to a project are ""Understand the goals, evaluate the impact on the project, create a list of functionality requirements, and develop the requirements of the feature." (Option C)
How is this so?
The core steps to add revisions or features to a project include understanding the goals,evaluating the impact on the project, creating a list of functionality requirements,and developing the requirements of the feature.
These steps ensure that the goals are clear, the impact is assessed, and the necessary functionality is identified and implemented effectively.
Learn more about project management at:
https://brainly.com/question/16927451
#SPJ1
Yahtzee is a dice game that uses five die. There are multiple scoring abilities with the highest being a Yahtzee where all five die are the same. You will simulate rolling five die 777 times while looking for a yahtzee.
Program Specifications :
Create a list that holds the values of your five die.
Populate the list with five random numbers between 1 & 6, the values on a die.
Create a function to see if all five values in the list are the same and IF they are, print the phrase "You rolled ##### and its a Yahtzee!" (note: ##### will be replaced with the values in the list)
Create a loop that completes the process 777 times, simulating you rolling the 5 die 777 times, checking for Yahtzee, and printing the statement above when a Yahtzee is rolled.
convert 423 from base 5 to base 3
(show work)
To convert 423 from base 5 to base 3:
423 (base 5) = 11121 (base 3)
To convert the number 423 from base 5 to base 3, follow these step-by-step explanations:
Step 1: Write down the number in base 5.
423 (base 5)
Step 2: Convert the number from base 5 to base 10.
4 * 5^2 + 2 * 5^1 + 3 * 5^0
= 4 * 25 + 2 * 5 + 3 * 1
= 100 + 10 + 3
= 113 (base 10)
Step 3: Convert the number from base 10 to base 3.
To convert from base 10 to base 3, divide the number repeatedly by 3 and record the remainders.
113 ÷ 3 = 37 with a remainder of 2
37 ÷ 3 = 12 with a remainder of 1
12 ÷ 3 = 4 with a remainder of 0
4 ÷ 3 = 1 with a remainder of 1
1 ÷ 3 = 0 with a remainder of 1
Reading the remainders in reverse order gives us the base 3 representation.
The number 423 (base 5) is equal to 11121 (base 3).
Therefore, 423 (base 5) is equivalent to 11121 (base 3).
For more such question on base
https://brainly.com/question/9624014
#SPJ8
A STUDENT IS GRADED BASED ON EXAM PERFORMANCE AND CLASS ATTENDANCE.WHEN THE PERFORMANCE IS ABOVE 50% AND CLASS ATTENDANCE GREATER THAN 75%,THE STUDENT IS AWARDED "PASS".WHEN THE CLASS ATTENDANCE IS LESS THAN 75%,THE STUDENT RETAKES THE COURSE.OTHERWISE,THE SITS FOR A SUPPLEMENTARY EXAM.DRAW A PROGRAM FLOWCHART TO REPRESENT THIS LOGIC
Here is a flowchart to represent the logic described:
The FlowchartSTART
|
v
ENTER exam performance and class attendance
|
v
IF performance > 50 AND attendance > 75 THEN
|
v
DISPLAY "PASS"
|
v
ELSE IF attendance < 75 THEN
|
v
DISPLAY "RETAKE COURSE"
|
v
ELSE
|
v
DISPLAY "SUPPLEMENTARY EXAM"
|
v
END
Using symbols, flow charts depict the connections between input, processes, and output.
The planned structure of a program is analyzed by computer programmers using flow charts to ensure that all inputs, processes, and outputs have been considered and that all defects have been fixed. Flow charts are used to communicate ideas to stakeholders.
Read more about flowcharts here:
https://brainly.com/question/6532130
#SPJ1
Drag the tiles to the correct boxes to complete the pairs.
Match each task to the type of control structure represents.
switch case
sequence
repetition
if else
assembling structure step by step
choosing between two subjects
selecting a color out of five colors
testing a product until free of bugs
Answer:
A structure choosing between two subjects - Switch case sequence
Selecting a color out of five colors - If else assembling
Testing a product until free of bugs - Repetition
what is digital literacy? describe three examples of digital literacy skills
Digital literacy means having the skills you need to live, learn, and work in a society where communication and access to information is increasingly through digital technologies like internet platforms, social media, and mobile device
Examples of Digital Literacy skills:
What is digital literacy?
ICT proficiency.
Information literacy.
Digital scholarship.
Communications and collaborations.
Digital learning.
Digital identity.
Need help with Exercise 5 (JAVA)
Using knowledge in computational language in JAVA it is possible to write a code that install java and set java home to point to the java installation directory.
Writting the code:
For Maven I tried :
1. open cmd
2. type mvn -version
3. Error appeared :
C:\Users\Admin>mvn -version
ERROR: JAVA_HOME is set to an invalid directory.
JAVA_HOME = "C:\Program Files\Java\jre7\bin"
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation
For ANT I tried and worked :
1. open cmd
2. type mvn -version
3. Apache Ant(TM) version 1.9.1 compiled on May 15 2013
There are multiple ways to copy elements from one array in Java, like you can manually copy elements by using a loop, create a clone of the array, use Arrays. copyOf() method or System. arrayCopy() to start copying elements from one array to another in Java.
See more about java at:
brainly.com/question/12975450
#SPJ1
describe what Professionalism means to you identify what you think is most important topic and they topic and explain how it affects the patient to payment process
Answer:
Professionalism is called the quality of certain workers by which their abilities are weighed at the time of carrying out their work, as well as the responsibility with which they carry out their tasks. Therefore, professionalism implies not only a skill but also an attitude when working.
Therefore, professionalism is a positive quality by which workers or professionals who carry out their activities in a positive way are characterized.
In what year was napier bone invented
The Napier's Bones is a manually-operated calculating device, invented by the Scottish mathematician John Napier in the early 17th century, around the year 1617.
What is Napier bone used for?Napier's Bones, also known as Napier's rods, are used for multiplication, division, and square root calculations. The device consists of a set of rectangular rods or bones with each bone representing a single digit in the multiplication table.
By manipulating the rods, users can quickly perform calculations that would otherwise be time-consuming to complete by hand. The Napier bone is an early example of a calculating device and is considered a predecessor to modern mechanical calculators.
Learn more about Napier bone at:
https://brainly.com/question/24242764
#SPJ1
Your company has been assigned the 194.10.0.0/24 network for use at one of its sites. You need to calculate a subnet mask that will accommodate 60 hosts per subnet while maximizing the number of available subnets. What subnet mask will you use in CIDR notation?
To accommodate 60 hosts per subnet while maximizing the number of available subnets, we need to use a subnet mask that provides enough host bits and subnet bits.
How to calculateTo calculate the subnet mask, we determine the number of host bits required to accommodate 60 hosts: 2^6 = 64. Therefore, we need 6 host bits.
Subsequently, we determine the optimal quantity of subnet bits needed to increase the quantity of accessible subnets: the formula 2^n >= the amount of subnets is used. To account for multiple subnets, the value of n is set to 2, resulting in a total of 4 subnets.
Therefore, we need 2 subnet bits.
Combining the host bits (6) and subnet bits (2), we get a subnet mask of /28 in CIDR notation.
Read more about subnet mask here:
https://brainly.com/question/28390252
#SPJ1
Which invention made it possible to have an entire computer for a single circuit board
Answer:
ok lang
Explanation:
plz help me of this question
its not be seen clearly bro
Split the worksheet into panes at cell G1.
Answer:
1. Select below the row where you want the split, or the column to the right of where you want the split.
2. On the View tab, in the Window group, click Split.
Explanation:
Which phrase or phrases suggest a security issue in data mining?
Travis often BUYS BUSINESS BOOKS ONLINE. Recently, he LOGGED INTO THE WEBSITE to buy a marketing book. He noticed a part on the screen that RECOMMENDED BOOKS BASED ON HIS BROWNING HISTORY. Due to this recommendation, Travis could easily locate the book. A few days later, he FOUND BOOK RECOMMENDATIONS FROM UNKNOW SOURCES. Eventually, he STARTED GETTING SPAM EMAIL FROM THESE SOURCES.
Based on web search results, data mining security issues are related to the protection of data and its resources from unauthorized access, misuse, or theft. Some of the factors that can suggest a security issue in data mining are:
- Data provenance: The source and history of the data should be verified and traced to ensure its authenticity and integrity.
- Access controls: The identity of the person or system accessing the data should be verified and authorized to prevent unauthorized access.
- Data anonymization: The sensitive or private information in the data should be masked or removed to protect the privacy of individuals or entities.
- Data storage location: The location where the data is stored should be secure and compliant with the relevant laws and regulations.
- Distributed frameworks: The data should be encrypted and protected when it is transferred or processed across different nodes or systems.
Based on these factors, the phrase or phrases that suggest a security issue in data mining in your question are:
- FOUND BOOK RECOMMENDATIONS FROM UNKNOWN SOURCES
- STARTED GETTING SPAM EMAIL FROM THESE SOURCES
These phrases indicate that the data provenance and access controls were compromised, and that the data was exposed to unauthorized parties who could misuse it for malicious purposes.
Next, copy in your strip_punctuation function and define a function called get_pos which takes one parameter, a string which represents one or more sentences, and calculates how many words in the string are considered positive words. Use the list, positive_words to determine what words will count as positive. The function should return a positive integer - how many occurrences there are of positive words in the text. Note that all of the words in positive_words are lower cased, so you’ll need to convert all the words in the input string to lower case as well.
punctuation_chars = ["", ","," 3 # list of positive words to use 4 positive_words = 0 5 with open ("positive_words.txt") as pos_f: for lin in pos_f: if lin[0] != ';' and lin[0] != '\n': positive_words.append(lin.strip) 6 7 8 9 10
Answer:
Here is the get_pos function:
def get_post(string): #function that takes string as parameter
string=string.lower() #converts the string to lower case
string=strip_punctuation(string) #calls strip_punctuation to remove punctuation from string
string=string.split() #split the string into a list
count_positive=0 #counts the occurrences of positive words
for word in string: #loops through the string
if word in positive_words: #if a word in a string is a positive words
count_positive=count_positive+1 #adds 1 to the count of count_positive each time a positive word appears
return count_positive #returns the positive integer - how many occurrences there are of positive words in the string
Explanation:
In order to explain the working of this function lets suppose the punctuation_chars list contains the following punctuation characters:
punctuation_chars = ["'", '"', ",", ".", "!", ":","?", ";", '#']
Lets suppose the positive_words.txt file contains the following two words i.e. yes okay
Lets suppose the string is Hi! I am okay, see you later.
string = " Hi! I am okay, see you later. "
string=string.lower() statement converts the string to lower case:
string = hi! i am okay, see you later.
string=strip_punctuation(string) this statement calls strip_punctuation method to remove the punctuation from string.
string = hi i am okay see you later
string=string.split() this statement splits the sentence into list
['hi', 'i', 'am', 'okay', 'see', 'you', 'later']
for word in string: this loop iterates through the string
At first iteration if condition checks if word "hi" is in positive_words. This is not true because positive_words only contain the words okay and yes.
At next iteration if condition checks if word "i" is in positive_words. This is not true because positive_words only contain the words okay and yes.
At next iteration if condition checks if word "am" is in positive_words. This is also not true.
At next iteration if condition checks if word "okay" is in positive_words. This is true because positive_words contains the words okay. So count_positive=count_positive+1 statement executes which adds 1 to the count of count_positive so
count_positive = 1
At next iteration if condition if word in positive_words checks if word "see" is in positive_words. This is not true.
At next iteration if condition checks if word "you" is in positive_words. This is also not true.
At next iteration if condition checks if word "later" is in positive_words. This is also not true.
Now the statement: return count_positive returns the occurrence of positive words in the string which is 1. So the output of this is 1.
Here is the strip_punctuation method:
def strip_punctuation(word): #removes punctuation from words
New_word="" #initializes new word string to empty
print("Word is: ",word) #prints the word
for w in word: #iterates through words
if w not in punctuation_chars: #if word is not in punctuation_char list
New_word=New_word+w #adds that word to new word string
return New_word #returns word after removing punctuation
Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise. For example: function call return value is_pow2(1) True is_pow2(2) True is_pow2(3) False is_pow2(4) True is_pow2(5) False is_pow2(6) False is_pow2(7) False is_pow2(8) True is_pow2(9) False is_pow2(255) False is_pow2(256) True Hint: Consider using repeated floor division.
Answer:
In Python:
def is_power(n):
if n > 2:
n = n/2
return is_power(n)
elif n == 2:
return True
else:
return False
Explanation:
This defines the function
def is_power(n):
If n is greater than 0
if n > 2:
Divide n by 2
n = n/2
Call the function
return is_power(n)
If n equals 2
elif n == 2:
Return True
return True
If n is less than 2
else:
Then, return false
return False