In python,
Part 1: Estimate the value of e.
e is defined as as n goes to infinity. So the larger the value of n, the closer you should get to e.
math.e is defined as 2.718281828459045
You'll write a program that uses a while loop to estimate e to within some defined error range, while having a limit on how many iterations it will attempt.
Part 2: Palindrome detection
A palindrome is a string that is the same forwards and backwards.
Madam I'm Adam
Racecar
Was it a cat I saw?
There are many sophisticated ways of detecting palindromes. Some are surprisingly simple (s == s[::-1])
You will use a for loop to iterate over the contents of the string to determine if it is a palindrome.
Beware! There are many solutions online. Don't fall prey to looking this one up. It's not as hard as it looks. Draw it out on paper first and think through how you index the string from both ends.
skeleton of code:
#
# Estimate the value of e.
#
# Write a routine that uses a while loop to estimate e.
#
# Arguments:
# delta: How close the estimate
has to come
#
n: Maximum number of attempts
#
# Algorithm:
# Compare math.e to your value
of e and if the difference is
# greater than delta, increment
count and make a new estimate. A
# Assuming the count variable
is "i", the formula for e is:
# e =
(1 + 1/i)**i
#
# Stop when the difference
between math.e and your value is less
# than delta or the count
variable reaches n.
#
# Output:
# Return a tuple of the delta
and the number of tries you made
#
import math
def estimateE(delta, n):
pass
#
# Return true if s is a palindrome
#
# Look at the indices of a string s = "abcdcba":
# 0, 1, 2, 3, 4, 5, 6
# -7, -6, -5, -4, -3, -2, -1
#
# To be a palindrome, s[0] == s[-1], s[1] == s[-2], etc
#
# Return True if s is a palindrome
#
# Use ONLY a for loop, len, and slicing.
#
def palindrome(s):
pass
#
# Don't change the lines below! They run the tests for grade
evaluation!
#
def main():
print(palindrome("abcdef"))
print(palindrome("abcdcba"))
print(palindrome("abba"))
print(palindrome("abccba"))
r = estimateE(0.01, 10)
print("{0:6.4}".format(r[0]), r[1]) # Prints
0.1371, 10
r = estimateE(0.01, 100)
print("{0:6.4f}".format(r[0]), r[1]) # Prints
0.0136, 100
r = estimateE(0.01, 1000)
print("{0:6.4f}".format(r[0]), r[1]) # Prints
0.0100, 136
#
# Only run testcases if this is main
#
if __name__ == "__main__":
main()
In: Computer Science
Write a C++ program that inputs three integers in the range [1..13] that represent a hand of three cards. Your program should output an English evaluation of the hand.
In the output, cards will be described as follows:
- 2–10 are described by the words for their numeric values: two, three, etc.
- 1 is called an ace, 11 is called a jack, 12 is called a queen, and 13 is called a king.
The evaluation of a hand is based on the first of the following cases that matches the cards:
- All three cards are equal to each other.
Sample output for 4 4 4: You have three fours.
- The three cards form a straight (three successive values).
Sample output for 6 8 7: You have an eight-high straight.
- Two cards (a pair) are equal.
Sample output for 6 3 6: You have a pair of sixes.
- Whatever is the highest card.
Sample output for 11 1 8: You have a jack.
Recommend sorting the card values before trying to evaluate the hand –that makes it much easier. Also, work on one thing at a time: first determine what kind of hand (3 of kind, 2 of kind, straight,...) and then determine what is the “significant” card for that hand (it becomes very messy and exhausting if you try to do both at the same time!). Check for card values being equal to each other (card1 == card2), not specific values (card1 == 1 && card2 == 1 || card1 == 2 && card 2 == 2 || ...). If you check each value, your program will be hundreds of lines long!
In: Computer Science
need mainly the php file and how to do the "value" portion
use pregmatch to verify proper format in the php file if able.
Create an HTML form that will accept four fields: first name, last name, user ID, and values. Name this file userInfo.html. There should be a submit and reset button on your html form. Your input fields for your form should be inside of a table. The submit button should send the data to a php file named updateInfo.php. The updateInfo.php file should check the data submitted by the html file for proper formatting. While it is allowable that you may check input on the client side (either HTML or Javascript), you MUST check for valid input on the server using PHP. (It will be easier to test your code if you don’t bother doing any checks on the HTML side – you will have to disable the checks on your own code to test the bad inputs).
***IMPORTANT***
Your POST variables in your HTML file must be labeled as follows. I have written an automated script to run tests on your code, and it depends on the POST variables being labeled correctly within the HTML Form.
The following rules must be enforced by your PHP script about the input.
9.3,100.0,45.5,43.0,0.7,0.0,76.9,1.0
If any field has invalid data, display an error message and a link back to the userInfo.html page. Do not write invalid data to the text file, or to the html table. Ignore all data when an entry is invalid.
If all the fields are valid, your PHP script should save the data into a file named userInfo.txt which should have the following format and be sorted by “last_name”. (Note you will need to read in the existing file’s data and add the new data to your data structure, and sort it before you can write the new file in the proper order). Put each record on its own line. To simplify things, you can assume that Last Names are unique – i.e. you can use the last name as a key for your associative array. (I won’t use two of the same last name when I test your code).
LastName--FirstName--UserID--Min,Max,Average;\n
Here is a sample record (a single line) of what should be in your text file:
Doe--John--abc123--3.4,99.9,45.4;
You can see from this that you will need to process the input values from the user to determine the min value, the max value, and the average. To be clear, you don’t need to store all the values entered, just the minimum, the maximum, and the average.
Once the new data has been received, you should also display ALL data from the text file into an HTML table. The table should be sorted by last name just like the text file. After successfully displaying your table, create a link back to the userInfo.html page. You should have 6 columns in your HTML file, with an appropriate header for each column.
In: Computer Science
Assume a scenario where the hackers gained access to information through malware on Point-of-Sale (POS) systems of more than million credit and debit card. The firewall had captured the first malware code and an alert was issued which was ignored. The hackers started downloading the collected data. The cyber criminals have hacked the system to gain credit and debit card information.
1. Explain in your own words what happened in the above discussed data breach. [5 Marks]
2. Identify and experience the type of attack experienced in the above scenario [2 Marks]
3. The stolen credentials alone are not enough to access the company’s POS devices. What other means can the hackers acquire to allow them to navigate the company’s network and deploy the malware. [3 Marks]
4. What would have hackers done for privilege escalation? [2 Marks]
5. The organization admitted that they ignored many alerts from their network security devices because of alert overload. If you are the organization’s Chief Technical Officer (CTO), what would you do to reduce the problem of alert overload? [3 Marks]
6. The security experts criticize the organization for failing to isolate sensitive sections of their networks from those more easily accessible to outsiders. As a CTO, please propose a feasible solution to segment and categorize your networks and resources. [5 Marks]
In: Computer Science
Enterprise Architecture
Describe the Application Structure viewpoint in terms of Stakeholders, Concerns, Purpose and Scope. [ 10 marks ] 1 page / 250 words
In: Computer Science
What are the trade-offs between speed, volatility, access method, portability, cost, and capacity with regard to storage for computers.
Specifically the relationship between cost and capacity.
In: Computer Science
A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x 3 + c2x 2 + c1x + c0, where x and the four coefficients are integers for this exercise. Suppose the values of the coefficients c0, c1, c2, and c3have been loaded into registers $t0, $t1, $t2, and $t3, respectively. Suppose the value of x is in $t7.
Write the MIPS32 instructions that would evaluate this polynomial, placing the result in $t9.
In: Computer Science
Assume a scenario where the hackers gained access to information through malware on Point-of-Sale (POS) systems of more than million credit and debit card. The firewall had captured the first malware code and an alert was issued which was ignored. The hackers started downloading the collected data. The cyber criminals have hacked the system to gain credit and debit card information.
1. Explain in your own words what happened in the above discussed data breach. [5 Marks]
2. Identify and experience the type of attack experienced in the above scenario [2 Marks]
3. The stolen credentials alone are not enough to access the company’s POS devices. What other means can the hackers acquire to allow them to navigate the company’s network and deploy the malware. [3 Marks]
4. What would have hackers done for privilege escalation? [2 Marks]
5. The organization admitted that they ignored many alerts from their network security devices because of alert overload. If you are the organization’s Chief Technical Officer (CTO), what would you do to reduce the problem of alert overload? [3 Marks]
6. The security experts criticize the organization for failing to isolate sensitive sections of their networks from those more easily accessible to outsiders. As a CTO, please propose a feasible solution to segment and categorize your networks and resources. [5 Marks]
In: Computer Science
Assume a scenario where the hackers gained access to information through malware on Point-of-Sale (POS) systems of more than million credit and debit card. The firewall had captured the first malware code and an alert was issued which was ignored. The hackers started downloading the collected data. The cyber criminals have hacked the system to gain credit and debit card information.
1. Explain in your own words what happened in the above discussed data breach. [5 Marks]
2. Identify and experience the type of attack experienced in the above scenario [2 Marks]
3. The stolen credentials alone are not enough to access the company’s POS devices. What other means can the hackers acquire to allow them to navigate the company’s network and deploy the malware. [3 Marks]
4. What would have hackers done for privilege escalation? [2 Marks]
5. The organization admitted that they ignored many alerts from their network security devices because of alert overload. If you are the organization’s Chief Technical Officer (CTO), what would you do to reduce the problem of alert overload? [3 Marks]
6. The security experts criticize the organization for failing to isolate sensitive sections of their networks from those more easily accessible to outsiders. As a CTO, please propose a feasible solution to segment and categorize your networks and resources. [5 Marks]
In: Computer Science
*******************In Python please*******************
(1) Prompt the user to enter a string of their choosing. Store the text in a string. Output the string. (1 pt)
Enter a sample text:
we'll continue our quest in space. there will be more shuttle
flights and more shuttle crews and, yes; more volunteers, more
civilians, more teachers in space. nothing ends here; our hopes and
our journeys continue!
You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
(2) Implement a print_menu() function, which has a string as a parameter, outputs a menu of user options for analyzing/editing the string, and returns the user's entered menu option and the sample text string (which can be edited inside the print_menu() function). Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a valid choice. Hint: Implement the Quit menu option before implementing other options. Call print_menu() in the main section of your code. Continue to call print_menu() until the user enters q to Quit. (3 pts)
Ex:
MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit
Choose an option:
(3) Implement the get_num_of_non_WS_characters() function. get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the print_menu() function. (4 pts)
Ex:
Number of non-whitespace characters: 181
(4) Implement the get_num_of_words() function. get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the print_menu() function. (3 pts)
Ex:
Number of words: 35
(5) Implement the fix_capitalization() function. fix_capitalization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capitalization() also returns the number of letters that have been capitalized. Call fix_capitalization() in the print_menu() function, and then output the the edited string followed by the number of letters capitalized. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string. (3 pts)
Ex:
Number of letters capitalized: 3
Edited text: We'll continue our quest in space. There will be more
shuttle flights and more shuttle crews and, yes; more volunteers,
more civilians, more teachers in space. Nothing ends here; our
hopes and our journeys continue!
(6) Implement the replace_punctuation() function. replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_punctuation() in the print_menu() function, and then output the edited string. (3 pts)
Ex: Punctuation replaced
exclamation_count: 1
semicolon_count: 2
Edited text: we'll continue our quest in space. there will be more
shuttle flights and more shuttle crews and, yes, more volunteers,
more civilians, more teachers in space. nothing ends here, our
hopes and our journeys continue.
(7) Implement the shorten_space() function. shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the print_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). (3 pt)
Ex:
Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
In: Computer Science
Design a program that will ask the user to input two integer numbers and then perform the basic arithmetic operations such as addition and subtraction. Each calculation is done by a separate function. The main function gets the input from the user, then calls the addition function and the subtraction function one at a time to perform the calculations. Each calculation function (addition or subtraction function) performs an arithmetic operation and then returns the calculation results back to where it was called. The main function then calls the display function to display the results for the user on the screen. Note, the display function is already developed for you. For each set of numbers the user entered, the program produces the sum and the difference of the values. You may assume the difference is calculated by the first number subtracts the second number that the result may yield a negative number.
Draw an IPO chart and a Pseudocode program for each function . Besides, apply all the techniques you've learned, be sure to document your programs and apply good programming styles.
I want to ask if I need to declare additional variables to hold the arguments being sent to the display function.
Function void main()
// Declare the Variables.
Declare integer num1, num2, total, total2
// Display Greeting message.
Display "Input two integer numbers."
Display "And I will tell you the sum and difference of the two numbers"
// Prompt User for the first number.
Display "Enter the first number: "
Input num1
// Prompt User for the second number.
Display "Enter the second number: "
input num2
// Get the sum of both numbers.
Set total = addition(num1, num2)
// Get the difference of both numbers.
Set total2 = subtraction(num1, num2)
// Send the results to the display function.
Set total = display() ---- I don't know if i need a variable in here?
Set total2 = display() ---- I don't know if I need a variable in here?
End Function
Function void display(Integer arg1, Integer arg2)
// Display the sum.
Display "The sum is",arg1
Display the difference.
Display "The difference is",arg2
End Function
P.S: I have already done the addition and subtraction modules.
In: Computer Science
4. In the key change operation of 20.15.7 Key Changes, suppose the manager simply transmitted delta2 = oldkey XOR newkey to the agent.
In: Computer Science
ssume a scenario where the hackers gained access to information through malware on Point-of-Sale (POS) systems of more than million credit and debit card. The firewall had captured the first malware code and an alert was issued which was ignored. The hackers started downloading the collected data. The cyber criminals have hacked the system to gain credit and debit card information. 1. Explain in your own words what happened in the above discussed data breach. [5 Marks] 2. Identify and experience the type of attack experienced in the above scenario [2 Marks] 3. The stolen credentials alone are not enough to access the company’s POS devices. What other means can the hackers acquire to allow them to navigate the company’s network and deploy the malware. [3 Marks] 4. What would have hackers done for privilege escalation? [2 Marks] 5. The organization admitted that they ignored many alerts from their network security devices because of alert overload. If you are the organization’s Chief Technical Officer (CTO), what would you do to reduce the problem of alert overload? [3 Marks] 6. The security experts criticize the organization for failing to isolate sensitive sections of their networks from those more easily accessible to outsiders. As a CTO, please propose a feasible solution to segment and categorize your networks and resources. [5 Marks]
In: Computer Science
An advisory practice was the target of an attack, whereby the malware allowed the fraudster to gain access to an adviser’s login details for all systems he had used recently. The fraudster now had access to every website or account that required a login. This included personal banking, platform desktop software, Xplan software and Facebook. The next time the adviser tried to log in to his platform desktop software, he was locked out. He rang our account executive team to report his access was locked. He couldn’t login, even though he was using his correct user name and password. The platform reset his password. The next day when the adviser tried again to login, he was locked out of the system again. It became obvious that the adviser’s user ID had been compromised. At this point, the user ID was deleted.
1. Identify the malware attack experienced in the above scenario
2. What recommendations would you provide for preventing such type of attacks? The recommendations should be discussed individually for the scenario and should not be a general list of recommendations
In: Computer Science
Report for Movie: Prometheus
What AI techniques/methods/devices/applications were mentioned in the movie and How accurate are the AI predictions on the movie set in our present time? Or, how realistic are those predictions if the time is yet to come?(400 words or above)
In: Computer Science