Answer:
I am writing a Python program:
def string_finder(target,search): #function that takes two parameters i.e. target string and a search string
position=(target.find(search))# returns lowest index of search if it is found in target string
if position==0: # if value of position is 0 means lowers index
return "Beginning" #the search string in the beginning of target string
elif position== len(target) - len(search): #if position is equal to the difference between lengths of the target and search strings
return "End" # returns end
elif position > 0 and position < len(target) -1: #if value of position is greater than 0 and it is less than length of target -1
return "Middle" #returns middle
else: #if none of above conditions is true return not found
return "not found"
#you can add an elif condition instead of else for not found condition as:
#elif position==-1
#returns "not found"
#tests the data for the following cases
print(string_finder("Georgia Tech", "Georgia"))
print(string_finder("Georgia Tech", "gia"))
print(string_finder("Georgia Tech", "Tech"))
print(string_finder("Georgia Tech", "Idaho"))
Explanation:
The program can also be written in by using string methods.
def string_finder(target,search): #method definition that takes target string and string to be searched
if target.startswith(search): #startswith() method scans the target string and checks if the (substring) search is present at the start of target string
return "Beginning" #if above condition it true return Beginning
elif target.endswith(search): #endswith() method scans the target string and checks if the (substring) search is present at the end of target string
return "End"#if above elif condition it true return End
elif target.find(search) != -1: #find method returns -1 if the search string is not in target string so if find method does not return -1 then it means that the search string is within the target string and two above conditions evaluated to false so search string must be in the middle of target string
return "Middle" #if above elif condition it true return End
else: #if none of the above conditions is true then returns Not Found
return "Not Found"
Complete question is:
Assume there is a machine with the IP address 129.82.102.63 with netmask /23, and with a parent NW whose netmask is 255.255.224.0.
For each answer, do not include any spaces, give full IP addresses/netmasks where these are requested, give the "/" as part of the answer for slash notation.
a. What is the parent NW's netmask in dotted decimal notation?
b. What is the parent NW's netmask in slash notation?
c. What is the child NW's (subnet's) netmask in dotted decimal notation?
d. What is the child NW's (subnet's) netmask in slash notation?
e. How many bits are there for host # portion for the parent NW? (Another way to say the same thing is How many bits do we manage - on the parent NW?)
f. How many bits are there for NW# portion (within the parent address space) for the subnet?
g. How many bits are there for host # portion for the subnet?
h. How many addresses can we assign to machines/interfaces on this subnet?
Answer:
a. 255.255.224.0
b. /19
255.255 amounts to 16 bits being 1. .224 means 3 more bits are 1. So, in total 19 bits are 1. Hence, total network bits are 16 + 3 = 19.
c. 255.255.254.0
/23 means 8 + 8 + 7 that means
first 2 octets are 1s and 7 bits out of the 3rd octet are 1s. Hence, /23 means 255.255.254.0
d. /23
e. 13 bits are reserved for hosts
Parent network mask is /19, so total 32-19 = 13 bits
f. 19 bits are reserved for the network in the parent address.
g. 9 bits
Subnetwork's mask is /23, so total 32-23 = 9 bits for the host portion.
h. Since 9 bits are reserved for hosts, a total of 29 -2 = 510 machines can be assigned the IP addresses. Two addresses will be network and broadcast addresses for the subnet that can't be allocated to any device.
Explanation:
Answer:
Here the code is given as,
Explanation:
Code:
#include <math.h>
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int v_stop = 0,count = 0 ;
int x;
double y;
int t_count [100];
double p_item [100];
double Total_rev = 0.0;
double cost_trx[100];
double Largest_element , Smallest_element;
double unit_sold = 0.0;
for( int a = 1; a < 100 && v_stop != -99 ; a = a + 1 )
{
cout << "Transaction # " << a << " : " ;
cin >> x >> y;
t_count[a] = x;
p_item [a] = y;
cost_trx[a] = x*y;
v_stop = x;
count = count + 1;
}
for( int a = 1; a < count; a = a + 1 )
{
Total_rev = Total_rev + cost_trx[a];
unit_sold = unit_sold + t_count[a];
}
Largest_element = cost_trx[1];
for(int i = 2;i < count - 1; ++i)
{
// Change < to > if you want to find the smallest element
if(Largest_element < cost_trx[i])
Largest_element = cost_trx[i];
}
Smallest_element = cost_trx[1];
for(int i = 2;i < count - 1; ++i)
{
// Change < to > if you want to find the smallest element
if(Smallest_element > cost_trx[i])
Smallest_element = cost_trx[i];
}
cout << "TRANSACTION PROCESSING REPORT " << endl;
cout << "Transaction Processed : " << count-1 << endl;
cout << "Uints Sold: " << unit_sold << endl;
cout << "Average Units per order: " << unit_sold/(count - 1) << endl;
cout << "Largest Transaction: " << Largest_element << endl;
cout << "Smallest Transaction: " << Smallest_element << endl;
cout << "Total Revenue: $ " << Total_rev << endl;
cout << "Average Revenue : $ " << Total_rev/(count - 1) << endl;
return 0;
}
Output:
calc_average - this function should accept 8 test scores as arguments and return the average of the scores per student
determine_grade - this function should accept a test score average as an argument and return a letter grade for the score based on the following grading scale:
90-100 A
80-89 B
70-79 C
60-69 D
Below 60 F
In this exercise we have to use the computer language knowledge in python to write the code as:
the code is in the attached image.
In a more easy way we have that the code will be:
def calc_average(name):
score = []
sum = 0
for j in range(8):
inp = int(input("Test Score"+str(j+1)+": "))
score.append(inp)
sum = sum + inp
if inp>=90 and inp<=100:
print("A")
elif inp>=80 and inp<90:
print("B")
elif inp>=70 and inp<80:
print("C")
elif inp>=60 and inp<70:
print("D")
else:
print("F")
avg = sum/8
print("Result Details of "+name)
print("Average Score: "+str(avg))
return avg
def determine_grade(result):
if float(result) >= 90.0 and float(result) <= 100.0:
print("Letter Grade: A")
elif float(result) >= 80.0 and float(result) <90.0:
print("Letter Grade: B")
elif float(result) >= 70.0 and float(result) < 80.0:
print("Letter Grade: C")
elif float(result) >= 60.0 and float(result) < 70.0:
print("Letter Grade: D")
else:
print("Letter Grade: F")
print(" ")
for i in range(2):
name = input("Student Name: ")
result = calc_average(name)
determine_grade(result)
See more about python at brainly.com/question/26104476
Answer:
The program doesn't make use of comments (See Explanation)
Also the source code is attached as image to enable you see the proper format and indexing of the source code
The program using python is as follows
def calc_average(name):
score = []
sum = 0
for j in range(8):
inp = int(input("Test Score"+str(j+1)+": "))
score.append(inp)
sum = sum + inp
if inp>=90 and inp<=100:
print("A")
elif inp>=80 and inp<90:
print("B")
elif inp>=70 and inp<80:
print("C")
elif inp>=60 and inp<70:
print("D")
else:
print("F")
avg = sum/8
print("Result Details of "+name)
print("Average Score: "+str(avg))
return avg
def determine_grade(result):
if float(result) >= 90.0 and float(result) <= 100.0:
print("Letter Grade: A")
elif float(result) >= 80.0 and float(result) <90.0:
print("Letter Grade: B")
elif float(result) >= 70.0 and float(result) < 80.0:
print("Letter Grade: C")
elif float(result) >= 60.0 and float(result) < 70.0:
print("Letter Grade: D")
else:
print("Letter Grade: F")
print(" ")
for i in range(2):
name = input("Student Name: ")
result = calc_average(name)
determine_grade(result)
Explanation:
def calc_average(name): -> Declares the function calc_average(name); It accepts local variable name from the main function
score = []
-> Initialize an empty list to hold test scores
sum = 0
-> Initialize sum of scores to 0
for j in range(8):
-> Iterate from test score 1 to 8
inp = int(input("Test Score"+str(j+1)+": "))
-> This line accepts test score from the user
score.append(inp)
-> The user input is then saved in a lisy
sum = sum + inp
-> Add test scores
The following lines determine the letter grade of each test score
if inp>=90 and inp<=100:
print("A")
---
else:
print("F")
avg = sum/8 -> Calculate average of the test score
The next two lines prints the name and average test score of the student
print("Result Details of "+name)
print("Average Score: "+str(avg))
return avg
-> This line returns average to the main method
The following is the determine_grade method; it takes it parameter from the main method and it determines the letter grade depending on the calculated average
def determine_grade(result):
if float(result) >= 90.0 and float(result) <= 100.0:
print("Letter Grade: A")
elif float(result) >= 80.0 and float(result) <90.0:
print("Letter Grade: B")
elif float(result) >= 70.0 and float(result) < 80.0:
print("Letter Grade: C")
elif float(result) >= 60.0 and float(result) < 70.0:
print("Letter Grade: D")
else:
print("Letter Grade: F")
print(" ")
for i in range(2):
-> This is the main method
name = input("Student Name: ") -> A local variable stores name of the student
result = calc_average(name) -> store average of scores in variable results
determine_grade(result)-> Call the determine_grade function
b. data
c. label
d. legend
Answer:
The screen protector may be interfering with the touch response
Explanation:
Screen protectors or commonly called screen guards are used to protect phone screens. In case they fall to the ground, these protectors act as shields to keep the phone screen from getting damaged. However screen protectors if not positioned or fixed properly may also cause hindrance to effective touch response as they become barriers to the touch screen.
In python:
year = int(input("Enter the school year: "))
if 0 <= year <= 5:
print("Elementary school")
elif 6 <= year <= 8:
print("Middle school")
elif 9 <= year <= 12:
print("High School")
elif 13 <= year <= 16:
print("College")
elif year >= 17:
print("Post-secondary")
else:
print("Invalid")
I hope this helps!