In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself). Write a Python3 program to check if a user-entered number is a perfect number or not. Use exception handling to handle invalid inputs.

Answers

Answer 1

Answer:

Explanation:

def the_perfect(n):

  try: #exception handling if n is a negative number

       n > 0

   except: #return -1 if the error is reached

       return -1

  else:

        total = 0

        for i in range(1, n): #for loop from 1 to the target number

           if n % i == 0:

               total += i

   return total == n  #should return true if number is perfect number

print(perfect_number(8))


Related Questions

We have seen in class that the sets of both regular and context-free languages are closed under the union, concatenation, and star operations. We have also seen in A2 that the regular languages are closed under intersection and complement. In this question, you will investigate whether the latter also holds for context-free languages.
(a) Use the languages A = {a^mb^nc^n \ m, n greaterthanorequalto 0} and B = {a^nb^nc^m \ m, n greaterthanorequalto 0} to show that the class of context-free languages is not closed under intersection. You may use the fact that the language C = {a^nb^nc^n | n greaterthanorequalto 0} is not context-free.
(b) Using part (a) above, show now that the set of context-free languages is not closed under complement.

Answers

Answer:

Attached is the solution. Hope it helps:

a) The class of context-free languages is not closed under intersection, as shown by the example of[tex]A = [ a^m b^n c^n | m, n \geq 0 ][/tex] and [tex]B = [a^n b^n c^m | m, n \geq 0 ][/tex]

Given that;

We have seen in class that the sets of both regular and context-free languages are closed under the union, concatenation, and star operations.

(a) We're given two languages A and B:

[tex]A = [ a^m b^n c^n | m, n \geq 0 ][/tex]

[tex]B = [a^n b^n c^m | m, n \geq 0 ][/tex]

We want to show that the intersection of A and B is not context-free.

To do this, we can use the fact that the language [tex]C = [a^n b^n c^n | n \geq 0 ][/tex] is not context-free.

Assume for contradiction that the intersection of A and B, which we'll call D, is context-free.

Since context-free languages are closed under intersection, we'd have D = A ∩ B is also a context-free language.

Now, notice that D is a subset of C (if a string belongs to D, it must belong to C as well).

However, C is not context-free, as given.

This contradicts our assumption that D is context-free.

Therefore, we can conclude that the class of context-free languages is not closed under intersection, as shown by the example of[tex]A = [ a^m b^n c^n | m, n \geq 0 ][/tex] and [tex]B = [a^n b^n c^m | m, n \geq 0 ][/tex]

(b) Using the result from part (a), we can now show that the set of context-free languages is not closed under complementation.

Let's consider the complement of a context-free language.

If the complement of a context-free language were always context-free, we could take the complement of C and obtain a context-free language.

However, as established earlier, C is not context-free.

Hence, we can conclude that the set of context-free languages is not closed under complementation.

Learn more about Programs here:

brainly.com/question/14368396

#SPJ3

Choose the correct code assignment for the following scenario:
15-year-old seen in the ER after being kicked by another soccer player today on a soccer field at the state soccer play-off tournament game.

a) W50.0XXA, Y92.213, Y93.66
b) W50.0XXA, Y92.322, Y93.6A
c) W50.1XXA, Y92.322, Y93.66
d) W50.1XXA, Y92.213, Y93.6A.

Answers

Answer:

C

Explanation:

W50.1XXA, Y92.322, Y93.66

Cheers

What is wrong with line 1?

public class G
{
private int x;
public G() { x=3;}
public void setX(int val){
x=val;
}
public String toString(){
return ""+x;
}
}

public class H extends G
{
private int y;
public H() { y=4;}
public void setY(int val){
y=val;
}
public String toString() {
return ""+y+super.toString();
}
}

//test code in the main method
G bad = new H();
bad.setY(9); //line 1

Answers

Answer:

The set is a object of the class 'H' and the setY method is a member of G class which is not called by the object of H class.

Explanation:

If a user calls the G function which is not a private by the help of H class objects then it can be called. It is because all the public and protected methods of A class can be accessed by the B class if B extends the A-class.If any class is extended by the other class then the derived class holds the property of the base class and the public and protected method can be accessed by the help of a derived class object.The derived class object can be created by the help of base class like written in the "line 1".But the base class can not call the member of the derived class.

Consider a point to point link 50 km in length. At what speed would propagation delay (at a speed 2 x 108 meters/second) equal transmit delay for 100 byte packets.

Answers

Answer:

The bandwidth is 3200 Kbps

Explanation:

Given:

The length of the point to point link = 50 km = 50×10³ = 50000 m

Speed of transmission = 2 × 10⁸ m/s

Therefore the propagation delay is the ratio of the length of the link to speed of transmission

Therefore,  [tex]t_{prop} = \frac{distance}{speed}[/tex]

[tex]t_{prop} = \frac{50000}{2*10^{8} }=2.5*10^{-4}[/tex]

Therefore the propagation delay in 25 ms

100 byte = (100 × 8) bits

Transmission delay = [tex]\frac{(100*8)bits }{(x)bits/sec}[/tex]

If propagation delay is equal to transmission delay;

[tex]\frac{(100*8)bits }{(x)bits/sec}= \frac{50000}{2*10^{8} }[/tex]

[tex]x=\frac{100*8*2*10^{8} }{50000}[/tex]

[tex]x=\frac{100*8}{2.5*10 ^-4}=3200000[/tex]

x = 3200 Kbps

Answer:

The complete question is here:

Consider a point-to-point link 2 km in length. At what bandwidth would propagation delay (at a speed of 2 x 108 m/s) equal transmission delay for

(a) 100-byte packets?

(b) 512-byte packets?

Explanation:

Given:

Length of the link = 50 km

Propagation delay = distance/speed = d/s

To find:

At what speed would propagation delay (at a speed 2 x 10^8 meters/second) equal transmit delay for 100 byte packets?

Solution:

Propagation Delay = t prop

                                 = 50 * 10^3 / 2 * 10^8

                                 = 50000 / 200000000

                                 = 0.00025

                                 = 25 ms

(a) When propagation delay is equal to transmission delay for 100 packets:

Transmission Delay = packet length / data rate = L / R

So when,

Transmission Delay = Propagation Delay

100 * 8  / bits/sec = 50 * 10^3  / 2 * 10^8

Let y denotes the data rate in bit / sec

speed = bandwidth = y bits/sec

         100 * 8  / y bits/sec = 50 * 10^3  / 2 * 10^8

                        y bit/sec   =  100 * 8  / 25 * 10^ -5

                                         = 800 / 0.00025

                                     y  = 3200000 bit/sec

                                      y = 3200 Kbps

(b) 512-byte packets

512 * 8  / y bits/sec = 50 * 10^3  / 2 * 10^8

                        y bit/sec   =  512 * 8  / 25 * 10^ -5

                                         = 4096 / 0.00025

                                     y  = 16384000 bit/sec

                                      y = 16384 Kbps

Read the PIC Data sheet Chapter 2.0 and 3.0 2. List at least 3 big differences between the Flash and RAM 3. How many RAM locations are there and how many bits in each location 4. How many Flash locations are there and how many bits in each location 5. Based on the diagram in figure 2-1, what memory are the configuration words associated with 6. In section 3.5.2 there is a description of Linear Data Memory". This is accessed using indirect addressing via the registers FS0 or FSland it allows one to have an array or buffer that is more than 80 bytes long. Explain why this is needed. 7. When you access data RAM, you must always make sure that the BSR is pointing to the right memory bank if you are using the normal mode of direct addressing. Are there any locations in data RAM where you don't have to worry about having the right bank selected? Explain your answer.

Answers

Final answer:

Flash and RAM are two types of memory used in microcontrollers like PIC, with differences such as Flash being non-volatile and RAM being volatile. Configuration words are usually stored in Flash memory, and special linear data memory can be used for larger structures. Even while accessing data RAM, the Bank Select Register should typically be set to the correct bank, but some common areas are accessible from all banks.

Explanation:

1. Flash and RAM are two types of memories used in microcontrollers like PIC, with significant differences. Flash Memory, being non-volatile, retains its information even when power is turned off, generally used for storing the program. On the other side, RAM (Random Access Memory) is volatile and loses its information when power is removed, typically used for temporary storage during program execution.

2+3. The specific number of RAM and Flash locations, as well as the bit size at each location, depends on the specific PIC microcontroller model. In general, one could read these details from the datasheet for the specific part.

4. Configuration words are usually associated with the Flash memory, as they are used to set up certain parameters for the chip that remain constant during operation.

5. Linear Data Memory is important for larger data structures such as arrays or buffers that require more than 80 bytes. Having this extra memory space allows more complex calculations and data manipulations.

6. Lastly, when accessing data RAM with direct addressing, the correct memory bank that includes our desired memory location should be selected into the BSR (Bank Select Register). However, there are ‘common’ areas in data RAM accessible from all banks, typically which include Special Function Registers (SFRs) and some general purpose registers.

Learn more about Memory Management in Microcontrollers here:

https://brainly.com/question/33223494

#SPJ3

Search online for a Request for Proposal relating to IT. Critically evaluate the proposal. If you were a vendor receiving this proposal, do you have enough information to reply with a quote. What is good? What is missing? What would you change?

Answers

Answer and Explanation:

The company of that same Pasadena area thereafter named as "Center" allows RFP to apply regarding contracts for Contractor, but should not be restricted to providing the information infrastructure facilities to complement the Centre's in-house development solutions at either the optimum level of benefits.The contractor or provider shall offer the best facilities on just the basis of the services listed in the preceding documentation by sending two formal submissions no earlier than noon 14 December 2016 to certain stakeholders are encouraged to react towards this RFP.Sure I would also have bought that if I were a dealer since it is worth the investment.

So, it's the right answer.

Consider the following architecture. 1 cache block = 16 words. Main memory latency is the time delay for each data transfer, which = 10 memory bus clock cycles. A memory transfer time = 1 memory bus clock cycle, which is also called bandwidth time. For any memory access, it consists of latency time plus the bandwidth time. The cache miss penalty is the time to transfer one block from main memory to the cache. In addition, it takes 1 clock cycle to send the address to the main memory. Compute the miss penalty for the following configurations. Configuration (a): Requires 16 main memory accesses to retrieve a cache block and words of the block are transferred one at a time. Configuration (b): Requires 4 main memory accesses to retrieve a cache block and words of the block are transferred four at a time. Configuration (c): Requires 4 main memory accesses to retrieve a cache block and words of the block are transferred one at a time.

Answers

Answer:

The answers are A)176 B)44 C)56.

Explanation:

According to the information given in the question about the architecture that is used and its communication times;

For option A: The goal is to retrieve one cache block which consists of 16 words. Doing this one word at a time over a period of 16 main memory accesses and the miss penalty for this configuration is 10*16 = 160 bus clock cycles for data transfer and 1*16 = 16 bus clock cycles for memory transfer time which comes up to 176.

For option B: The goal is to retrieve one cache block which consists of 16 words. Doing this four words at a time over a period of 4 main memory accesses and the miss penalty for this configuration is 10*4 = 40 bus clock cycles for data transfer and 1*4 = 4 bus clock cycles for memory transfer which comes up to 44.

For option C: The goal is to retrieve one cache block which consists of 16 words. Doing this 4 words at a time over a period of 4 main memory accesses and the miss penalty for this configuration is 10*4 = 40 bus clock cycles for data transfer and 1*16 = 16 bus clock cycles for memory transfer since words of the block are transferred not 4 but 1 at a time which comes up to 56.

I hope this answer helps.

A university begins Year 1 with 80 faculty. They hire 4 faculty each year. During each year 10% (rounded to the nearest integer) of the faculty present at the beginning of the year leave the university. For example, in a year where there are 73 faculty at the beginning of the year, 7 would leave the university at the end of the year. The university wants to know how many faculty they will have at the end of year 10. The resulting spreadsheet can be found below. In cell G9 the first cell address referred to was cell E9. If the formula is entered in cell G9 and is copied down to G10:G18, what is it followed by?

Answers

Answer:

The correct answer to the following question will be "B9:B18-ROUND(0.1*B9:B18,0) +C9:C18".

Explanation:

The ROUND function of Excel seems to be an adaptive feature in excel that calculates the first round amount of a specific number with either the numerical value or digits to be given as just a statement.

For rounding rolling quantities to a defined degree of accuracy you can use this function named ROUND.

The description of the above statement is as follow :

The formula will be used in that manner B9 along with colon B18 after that subtract (-) and using the round function (In this we pass the range i.e B9:B18,0) Plus C9 :C18.

Given three dictionaries, associated with the variables, canadian_capitals, mexican_capitals, and us_capitals, that map provinces or states to their respective capitals, create a new dictionary that combines these three dictionaries, and associate it with a variable, nafta_capitals.Use python and dictionary. Write code in simplest form.

Answers

Answer:

canadian_capitals = {"Alberta":"Edmonton", "British Columbia":"Victoria", "Manitoba":"Winnipeg"}

mexica_capitals ={"Aguascalientes":"Aguascalientes", "Baja California":"Mexicali", "Baja California Sur":"La Paz"}

us_capitals ={"Alabama":"Montgomery", "Alaska":"Juneau", "Arizona":"Phoenix"}

nafta_capitals = {}

nafta_capitals.update(canadian_capitals)

nafta_capitals.update(mexica_capitals)

nafta_capitals.update(us_capitals)

print(nafta_capitals)

Explanation:

The code is written in python.

canadian_capitals = {"Alberta":"Edmonton", "British Columbia":"Victoria", "Manitoba":"Winnipeg"}   I created the first dictionary with the variable name called canadian_capital.  Notice the province of Canada is mapped to to their respective capitals.

mexica_capitals ={"Aguascalientes":"Aguascalientes", "Baja California":"Mexicali", "Baja California Sur":"La Paz"}   I created the second dictionary with the variable name called mexican_capital. The states are also mapped to their respective capitals.

us_capitals ={"Alabama":"Montgomery", "Alaska":"Juneau", "Arizona":"Phoenix"}   I created the third dictionary with the variable name called us_capital.  The states are also mapped to their respective capitals.

nafta_capitals = {}  This is an empty dictionary with the variable name nafta_capitals to combine the 3 dictionaries.

nafta_capitals.update(canadian_capitals)  I updated the empty dictionary with the canadian_capitals dictionary.

nafta_capitals.update(mexica_capitals)  I also added the mexica_capitals dictionary to the nafta_capitals dictionary.

nafta_capitals.update(us_capitals)  I also added the us_capitals dictionary to the nafta_capitals dictionary.

print(nafta_capitals)   The whole 3  dictionaries have been combined to form the nafta_capitals dictionary. The print function displays the already combine dictionaries.

construct an AVL tree. For each line of the database and for each recognition sequence in that line, you will create a new SequenceMap object that contains the recognition sequence as its recognition_sequence_ and the enzyme acronym as the only string of its enzyme_acronyms_ main function

Answers

Answer:

Explanation:

AVL trees are used frequently for quick searching as searching takes O(Log n) because tree is balanced. Where as insertion and deletions are comparatively more tedious and slower as at every insertion and deletion, it requires re-balancing. Hence, AVL trees are preferred for application, which are search intensive.

The attached diagramm further ilustrate this

In this chapter, you saw an example of how to write an algorithm that determines whether a number is even or odd. Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even, and how many of them are odd.]

Answers

Answer:

// Program is written in Java Programming Language

// Comments are used for explanatory purpose

// Program starts here

public class RandomOddEve {

/** Main Method */

public static void main(String[] args) {

int[] nums = new int[100]; // Declare an array of 100 integers

// Store the counts of 100 random numbers

for (int i = 1; i <= 100; i++) {

nums[(int)(Math.random() * 10)]++;

}

int odd = 0, even = 0; // declare even and odd variables to 0, respectively

// Both variables will serve a counters

// Check for odd and even numbers

for(int I = 0; I<100; I++)

{

if (nums[I]%2 == 0) {// Even number.

even++;

}

else // Odd number.

{

odd++;

}

}

//.Print Results

System.out.print("Odd number = "+odd);

System.out.print("Even number = "+even);

}

Answer:

Complete python code along with comments to explain the whole code is given below.

Python Code with Explanation:

# import random module to use randint function

import random

# counter variables to store the number of even and odd numbers

even = 0

odd = 0

# list to store randomly generated numbers

random_num=[]

# A for loop is used to generate 100 random numbers

for i in range(100):

# generate a random number from 0 to 100 and append it to the list

   random_num.append(random.randint(0,100))

# check if ith number in the list is divisible by 2 then it is even

   if random_num[i] % 2==0:

# add one to the even counter

        even+=1

# if it is not even number then it must be an odd number

   else:

# add one to the odd counter

        odd+=1

# finally print the count number of even and odd numbers

print("Total Even Random Numbers are: ",even)

print("Total Odd Random Numbers are: ",odd)

Output:

Total Even Random Numbers are: 60

Total Odd Random Numbers are: 40

Total Even Random Numbers are: 54

Total Odd Random Numbers are: 46

write an assembly language procedure that also performs the binary search. The C program will time multiple searches performed by both the C code and your assembly language procedure and compare the result. If all goes as expected, your assembly language procedure should be faster than the C code.

Answers

Answer:

Let’s identify variables needed for this program.

First variables will be the one which will hold the values present in the Given Numbers in Array list and key of 16-bit and it will be array ARR and KEY. variables will be holding the Messages MSG1 “KEY IS FOUND AT “, RES ”  POSITION”, 13, 10,” $” and MSG2 ‘KEY NOT FOUND!!!.$’ to be printed for the User. Other variables will be holding Length of the Array and it will be LEN, So in all Six variables.

The identified variables are ARR, KEY, LEN, RES, MSG1 and MSG2.

DATA SEGMENT

    ARR DW 0000H,1111H,2222H,3333H,4444H,5555H,6666H,7777H,8888H,9999H

    LEN DW ($-ARR)/2

    KEY EQU 7777H

    MSG1 DB "KEY IS FOUND AT "

    RES DB "  POSITION",13,10," $"

    MSG2 DB 'KEY NOT FOUND!!!.$'

DATA ENDS

CODE SEGMENT  

   ASSUME DS:DATA CS:CODE

START:

     MOV AX,DATA

     MOV DS,AX

   

     MOV BX,00

     MOV DX,LEN

     MOV CX,KEY

AGAIN: CMP BX,DX

      JA FAIL

      MOV AX,BX

      ADD AX,DX

      SHR AX,1

      MOV SI,AX

      ADD SI,SI

      CMP CX,ARR[SI]

      JAE BIG

      DEC AX

      MOV DX,AX

      JMP AGAIN

BIG:   JE SUCCESS

      INC AX

      MOV BX,AX

      JMP AGAIN

SUCCESS: ADD AL,01

        ADD AL,'0'

        MOV RES,AL

        LEA DX,MSG1

        JMP DISP

FAIL: LEA DX,MSG2

DISP: MOV AH,09H

     INT 21H

     

     MOV AH,4CH

     INT 21H      

CODE ENDS

END START

In this Assembly Language Programming, A single program is divided into four Segments which are 1. Data Segment, 2. Code Segment, 3. Stack Segment, and 4. Extra  Segment. Now, from these one is compulsory i.e. Code Segment if at all you don’t need variable(s) for your program.if you need variable(s) for your program you will need two Segments i.e. Code Segment and Data Segment.

Explanation:

The attached Logic is a C like Program to conduct a binary search we need small Algorithm Shown above in a very simple way, So Just we will covert the logic into Assembly There are many things uncommon in the programing Language. There are No While Loops or Modules but this things are to be implemented in different ways.

Create a java program using the following instructions:GymsRUs has a need to provide fitness/health information to their clients including BMI, BMI category and maximum heart rate. Your task is to write a console program to do this. Body Mass Index (BMI) is a measure of body fat based on a person’s height and weight. BMI can be used to indicate if you are overweight, obese, underweight, or normal. The formula to calculate BMI is BMI = weight(lb) x 703 / (height(inches))^2.The following BMI categories are based on this calculation:Category BMI RangeUnderweight less than 18.5Normal 18.5 to less than 25Overweight 25 to less than 30Obese 30 or moreMax heart rate is calculated as 220 minus a person’s age.FUNCTIONAL REQUIREMENTS: This problem will have TWO classes. Design and code a class called HealthProfile (your "cookie cutter") to store information about clients and their fitness data. The following attributes are private instance variables:a. Nameb. Agec. Weightd. Height (total inches)

Answers

Answer:

See attached file for detailed code.

Explanation:

See attached file for explanation.

So far we have worked on obtaining individual digits from 4 digits of 5 digit numbers. The added them to find the sum of digits. However, now we know about the loop and we can remove the limit of having a specific number of digits. Write a program to print out all Armstrong numbers between 1 and n where n will be an user input. If the sum of cubes of each digit of the number is equal to the number itself, then the number is called an Armstrong number. For example, 153 = (1 * 1* 1)+ ( 5 * 5* 5 ) + ( 3*3*3) In order to solve this problem we will implement the following function: sumDigitCube(): write a function sumDigitCube() that takes a positive integer as a parameter and returns the sum of cube of each digit of the number. Then in the main function, take an integer n as input and generate each number from 1 to n and call the sumDigitCube() function. Based on the returned result, compares it with the value of the generated number and take a decision and print the number if it is Armstrong number

Answers

Answer:

#include<stdio.h>

int sumDigitCube(int n);

int main(){

   int n, i;

   printf("Enter number: ");

   scanf("%d", &n);

printf("The Armstrong numbers are:" );

   for(i=1; i<=n; i++){

       if(sumDigitCube(i)==i){

           printf(" %d", i);

       }

   }

   printf("\n");

   return 0;

}

int sumDigitCube(int n){

   int s = 0;

   int digit;

   while(n>0){

       digit = n%10;

       s += digit * digit *digit;

       n = n/10;

   }

   return s;

}

Explanation:

A company is utilizing servers, data storage, data backup, and software development platforms over an Internet connection.

Which of the following describes the company’s approach to computing resources?

a. Cloud computing

b. Client-side virtualization

c. Internal shared resources

d. Thick client computing

Answers

Answer:

The answer is A. Cloud computing

Explanation:

Cloud computing is the process of using the internet to store, mange and process data rather than using a local server or a personal computer.

The term  cloud computing is generally used to describe data centers available to many users over the Internet.  

Therefore the company's approach to computing resources can be said to be cloud computing because it uses the internet  for data storage, data backup, and software development  

Modify the URL_reader.py program to use urllib instead of a socket. This code should still process the incoming data in chunks, and the size of each chunk should be 512 characters.

Answers

Answer:see the picture attached

Explanation:

Write a program that generates a random integer number in the range of 1 through 100 inclusively, and then asks the user to guess what the number is (User should be informed at the beginning that the number is between 1 to 100). If the user’s guess (input) is higher than the random number, the program should display "Too high, try again." If the user’s guess is lower than the random number, the program should display "Too low, try again." If the user guesses the number, the program should congratulate the user with a message as well as to display the number of guesses to get the right number. Next asking the user if he/she wants to play one more time. If yes, then generate a new random number so the game can start over

Answers

Answer:

Here is the Python program:

import random  #to generate random numbers

low = 1  #lowest range of a guess

high = 100  #highest range of a guess

attempts=0   # no of attempts

def guess_number(low, high, attempts):  #function for guessing a number

   print("Guess a number between 1 and 100")      

#prompts user to enter an integer between 1 to 100 as a guess

   number = random.randint(low, high)  

#return randoms digits from low to high

   for _ in range(attempts):  #loop to make guesses

       guess = input("Enter a number: ")   #prompts user to enter a guess

       num = int(guess)  #reads the input guess

       if num == number:  # if num is equal to the guess number

           print('Congratulations! You guessed the right number!')    

           command= input("Do you want to play another game? ")

#asks user if he wants to play another game

           if command=='Y':  #if user enters Y  

               guess_number(low,high,attempts)  #starts game again

           elif command=='N':  #if user types N

               exit() #exits the program

       elif num < number:   #if user entered a no less than random no

           print('Too low, Try Higher')  # program prompts user to enter higher no

       elif num > number: #if user entered a no greater than random no

           print('Too high, Try Lower') # program prompts user to enter lower no

       else:  #if user enters anything else

           print("You must enter a valid integer.")  

#if user guessed wrong number till the given attempts

   print("You failed to guess the number correctly in {attempts} attempts.".format(attempts=attempts))  

   exit() # program exits

Explanation:

The program has a function guess_number which takes three parameters, high and low are the range set for the user to enter the number in this range and attempts is the number of tries given to the user to guess the number.

random.randint() generates integers in a given range, here the range is specified i.e from 1 to 100. So it generates random number from this range.

For loop keeps asking the user to make attempts in guessing a number and the number of tries the user is given is specified in the attempts variable.

If the number entered by the user is equal to the random number then this message is displayed: Congratulations! You guessed the right number! Then the user is asked if he wants to play one more time and if he types Y the game starts again but if he types N then the exit() function exits the game.

If the number entered as guess is higher than the random number then this message is displayed Too high, Try Lower and if the number entered as guess is lower than the random number then this message is displayed Too low, Try Higher.

If the user fails to guess the number in given attempts then the following message is displayed and program ends. You failed to guess the number correctly in {attempts} attempts.

You can call this function in main by passing value to this function to see the output on the screen.

guess_number(1, 100, 5)

The output is shown in screenshot attached.

Write the definition of a method printAttitude, which has an int parameter and returns nothing. The method prints a message to standard output depending on the value of its parameter. If the parameter equals 1, the method prints disagree. If the parameter equals 2, the method prints no opinion. If the parameter equals 3, the method prints agree. In the case of other values, the method does nothing.

Answers

Answer:

void printAttitude (int pint){

if (pint == 1){

System.out.println("disagree");

}

if (pint == 2){

System.out.println("no opinion");

}

if (pint == 3){

System.out.println("agree");

}

}

Explanation:

Answer:

public class num4 {

   public static void main(String[] args) {

       int para =2;

       printAttitude(para);

   }

   static void printAttitude( int para){

       if(para==1){

           System.out.println("disagree");

       }

       else if (para == 2){

           System.out.println("no option");

       }

       else if (para==3){

           System.out.println("agree");

       }

   }

}

Explanation:

Using Java Programming language:

Three if and else if statements are created to handle the conditions as given in the question (1,2,3) The output of disagree, no option and agree respectively is displayed using Java's output method System.out.println When these conditions are true

No else statement is provided to handle situations when the parameter value is neither (1,2,3), as a result, then program will do nothing and simply exits.

Write a script that will:

• Call a function to prompt the user for an angle in degrees.
• Call a function to calculate and return the angle in radians. (Note: π radians = 180°)
• Call a function to print the resultWrite all of the functions, also. Put the script and all functions in separate code files.

Answers

Answer:

The solution code is written in Python:

import math   def getUserInput():    deg = int(input("Enter an angle in degree: "))    return deg def calculateRad(deg):    return (deg * math.pi) / 180 def printResult(deg, rad):    print(str(deg) + " is equal to " + str(round(rad,2)) + " radian") degree = getUserInput() radian = calculateRad(degree) printResult(degree, radian)

Explanation:

Since we need a standard Pi value, we import math module (Line 1).

Next, create a function getUserInput to prompt user to input degree (Line 3-5).

Next, create another function calculateRad that take one input degree and calculate the radian and return it as output (Line 7-8).

Create function printResult to display the input degree and its corresponding radian (Line 10-11).

At last, call all the three functions and display the results (Line 13-15).

Given a integer, convert to String, using String Builder class. No error checking needed on input integer, However do read in the input integer using Scanner API. This program requires you to use a loop.

Answers

Answer:

The program in Java will be:

// Java program to demonstrate working parseInt()  

public class GFG  

{  

   public static void main(String args[])  

   {  

       int decimalExample = Integer.parseInt("20");  

       int signedPositiveExample = Integer.parseInt("+20");  

       int signedNegativeExample = Integer.parseInt("-20");  

       int radixExample = Integer.parseInt("20",16);  

       int stringExample = Integer.parseInt("geeks",29);  

 

       // Uncomment the following code to check  

       // NumberFormatException  

 

       //   String invalidArguments = "";  

       //   int emptyString = Integer.parseInt(invalidArguments);  

       //   int outOfRangeOfInteger = Integer.parseInt("geeksforgeeks",29);  

       //   int domainOfNumberSystem = Integer.parseInt("geeks",28);  

 

       System.out.println(decimalExample);  

       System.out.println(signedPositiveExample);  

       System.out.println(signedNegativeExample);  

       System.out.println(radixExample);  

       System.out.println(stringExample);  

   }  

}

Methods inherited from the base/super class can be overridden. This means changing their implementation; the original source code from the base class is ignored and new code takes its place. Abstract methods must be overridden.

Answers

Answer:

False

Explanation:

Methods inherited from the base/super class can be overridden only if behvior is close enough. The overridding method should have same name, type and number of parameters and same return type.

Answer:

False.this statement is false because, im not sure, but its for sure false.

Methods inherited from the base/super class can be overridden only if behvior is close enough. The overridding method should have same name, type and number of parameters and same return type.

Your supervisor manages the corporate office where you work as a systems analyst. Several weeks ago, after hearing rumors of employee dissatisfaction, he asked you to create a survey for all IT employees. After the responses were returned and tabulated, he was disappointed to learn that many employees assigned low ratings to morale and management policies.

This morning he called you into his office and asked whether you could identify the departments that submitted the lowest ratings. No names were used on the individual survey forms. However, with a little analysis, you probably could identify the departments because several questions were department-related.

Now you are not sure how to respond. The expectation was that the survey would be anonymous. Even though no individuals would be identified, would it be ethical to reveal which departments sent in the low ratings? Would your supervisor’s motives for wanting this information matter?

Answers

Maintaining confidentiality in employee surveys is essential to ensure honest feedback and protect employee trust. Identifying departments with low morale raises ethical considerations, particularly when the survey was intended to be anonymous.

Workplace Confidentiality and Ethical Dilemmas

When managing confidential employee surveys, such as an attitude survey, it is crucial to maintain the confidentiality of employees' responses. This is important for cultivating trust and fostering an environment where employees feel safe to express genuine concerns. The ethical dilemma arises when considering whether to identify departments with low morale based on non-anonymized data, which could breach confidentiality agreements and potentially erode trust. The intention behind identifying these departments is a crucial element to consider: if it's for the purpose of targeted improvements without repercussions, it may be more justifiable than if it were for punitive measures.

Organizational behavior research argues for the importance of maintaining confidentiality to get honest responses and the negative impacts when surveys lead to no action. Actionability from survey results is key, but it must respect the promised confidentiality. This also relates to issues of social desirability bias, where respondents may skew their answers to appear more favorable when anonymity isn't assured. Trust both in the confidentiality and the constructive use of survey data is vital for the ongoing success of such workplace assessments.

Any effort to identify departments from the survey data should be carefully weighed against ethical considerations, and if pursued, it should be done transparently and with a clear, constructive action plan to address the issues without targeting individuals.

A __________ grants the authority to perform an action on a system. A __________ grants access to a resource. right, permission login, password permission, right password, login

Answers

Answer:

A right grants the authority to perform an action on a system. A permission grants access to a resource.

Explanation:

In System administration there are different rights and permissions are given to the user as per the requirement to perform some actions and accessing some resources.

Rights are given to the users may be at admin level to perform some action or make some changes in the system. The users who have rights of the system can add, edit or delete data from the system as per requirement of the company.

Many peoples granted by permissions by providing them some passwords to access the resources of the systems. These users did not have the right to change, add, edit or delete any data. They just can use the information.

A right grants the authority to perform an action on a system. A permission grants access to a resource.

In the context of system security and access control:

- A right is a privilege granted to a user or process that allows them to perform a specific action on a system. For example, a right might allow a user to shut down the computer or to modify system settings.  

- A permission is a rule that grants access to a specific resource, such as a file, directory, or network resource. Permissions determine what actions (such as read, write, or execute) can be performed on that resource.

Thus, a right defines the actions a user can perform, while a permission defines what resources a user can access and what they can do with those resources.

Consider the following program:

void fun1(void); /* prototype */
void fun2(void); /* prototype */
void fun3(void); /* prototype */
void main() {
int a, b, c;
...
}
void fun1(void) {
int b, c, d;
...
}
void fun2(void) {
int c, d, e;
...
}
void fun3(void) {
int d, e, f;
...
}

Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during the execution of the last subprogram activated? Include with each visible variable the name of the unit where it is declared.
1. main calls sub1; sub1 calls sub2; sub2 calls sub3.
2. main calls sub1; sub1 calls sub3.
3. main calls sub2; sub2 calls sub3; sub3 calls sub1.
4. main calls sub3; sub3 calls sub1.
5. main calls sub1; sub1 calls sub3; sub3 calls sub2.

Answers

Answer:

Following are the variables which is visible in when the last module is called:

d,e,fd,e,fb,c,db,c,dc,d,e

Explanation:

Missing information :

The above question option needs to holds the function name as fun1,fun2 or fun3, but the options are holding the sub1,sub2, and sub3.The above question asked about the variable when the last function is called. The explanation of the visible variable is as follows:For the first option, the last function is called is fun3 which holds the variable as d,e, and f, and no variable is passed as the argument, So currently visible variable are d,e, and f.For the second option, the last function is called is fun3 which holds the variable as d,e, and f, and no variable is passed as the argument, So currently visible variable are d,e, and f.For the third option, the last function is called is fun1 which holds the variable as b,c and d and no variable is passed as the argument, So currently visible variable are b,c, and d.For the fourth option, the last function is called is fun1 which holds the variable as b,c and d and no variable is passed as the argument, So currently visible variable are b,c, and d.For the fifth option, the last function is called is fun2 which holds the variable as c,d and e and no variable is passed as the argument, So currently visible variable are c,d, and e.

The shipping charges per 500 miles are not prorated. For example, if a 2-pound package is shipped 550 miles, the charges would be $2.20. Write a program that asks the user to enter the weight of a package and then displays the shipping charges.

Answers

Answer:

The solution code is written in Python:

COST_PER_500MI = 1.1 weight = float(input("Enter weight of package: ")) total_cost = weight * COST_PER_500MI print("The shipping charges is $" + str(round(total_cost,2)))

Explanation:

Based on the information given in the question, we presume the cost per 500 miles is $1.10 per pound ($2.20 / 2 pound).

Create a variable COST_PER_500MI to hold the value of cost per 500 miles (Line 1). Next, prompt user input the weight and assign it to variable weight (Line 3). Calculate the shipping charge and display it using print function (Line 4-5).

Final answer:

A program to calculate shipping charges can be created by converting the weight of a package to ounces and using the provided rate structure. For a 2-pound package, the cost to ship would be $6.88, following the given rate system where the first 3 ounces cost $1.95 and each additional ounce costs $0.17. The per 500-mile charges are not prorated.

Explanation:

The given scenario requires the creation of a simple program that calculates shipping charges based on the weight of a package and the distance it needs to be shipped. According to the details, there's a flat rate for the first 3 ounces, and then an additional, per ounce charge after that. If a 2-pound package is shipped, we can calculate the cost based on the conversion of pounds to ounces, and then apply the pricing rules provided. Since there are 16 ounces in one pound, a 2-pound package would be equivalent to 32 ounces. The cost would then be computed as follows:

Total Cost = Base cost for first 3 ounces + (Number of additional ounces x Cost per additional ounce)

For a 32 ounce package, this would be:

Total Cost = $1.95 + (29 x $0.17) = $1.95 + $4.93 = $6.88

There is no need to prorate the charge per 500 miles as the example provided indicates a flat charge is applied per 500-mile increment. Handling user input correctly in a program is also essential to ensure the right calculations are made based on what the user enters for the package weight and distance.

Develop a Python program. Define a class in Python and use it to create an object and display its components. Define a Student class with the following components (attributes):  Name  Student number  Number of courses current semester

Answers

Answer:

class Student:    def __init__(self, Name, Student_Num, NumCourse):        self.Name = Name          self.Student_Num = Student_Num          self.NumCourse = NumCourse   s1 = Student("Kelly", 12345, 4) print(s1.Name) print(s1.Student_Num) print(s1.NumCourse)

Explanation:

Firstly, use the keyword "class" to create a Student class.

Next, create a class constructor (__init__) that takes input for student name, student number and number of course (Line 2) and assign the input to the three class attributes (Line 3-5). All the three class attributes are preceded with keyword self.

Next, create a student object (Line 7) and at last print all the attributes (Line 8-10).

Insect population An insect population doubles every generation. Write a while loop that iterates numGeneration times. Inside the while loop, write a statement that doubles currentPopulation in each iteration of the while loop. Function Save Reset MATLAB DocumentationOpens in new tab function currentPopulation = CalculatePopulation(numGeneration, initialPopulation) % numGeneration: Number of times the population is doubled % currentPopulation: Starting population value i = 1; % Loop variable counts number of iterations currentPopulation = initialPopulation; % Write a while loop that iterates numGeneration times while ( 0 ) % Write a statment that doubles currentPopulation in % each iteration of the while loop % Hint: Do not forget to update the loop variable end end 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Code to call your function

Answers

Answer:

function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)

    i = 1;

    currentPopulation = initialPopulation;

    while(i <= numGeneration)

         currentPopulation = 2* currentPopulation;

         i= i+1;

    end

end

Explanation:

Assign 1 to i as an initial loop value .Assign  initialPopulation to currentPopulation  variable.Run the while loop until i is less than numGeneration.Inside the while loop, double the currentPopulation  variable.Inside the while loop, Increment the i variable also.

In this exercise we have to use the knowledge of computational language in python to describe a code, like this:

The code can be found in the attached image.

To make it easier the code can be found below as:

function currentPopulation = CalculatePopulation(numGeneration, initialPopulation)

   i = 1;

   currentPopulation = initialPopulation;

   while(i <= numGeneration)

        currentPopulation = 2* currentPopulation;

        i= i+1;

   end

end

See more about python at brainly.com/question/26104476

The factorial of an integer N is the product of the integers between 1 and N, inclusive. Write a while loop that computes the factorial of a given integer N.

Answers

the function and loop will be

def factorial(x):

   total = 1

   if x != 1 and x != 0:

       for i in range(x,1,-1):

           total *= i

   return total

The program is an illustration of loops

Loops are program statements that are used to perform repeated operations

The program in python, where comments are used to explain each line is as follows:

#This gets input for N

N = int(input())

#This initializes factorial to 1

factorial = 1

#This opens the while loop

while N >1:

   #This calculates the factorial

   factorial*=N

   N-=1

#This prints the factorial

print(factorial)

Read more about loops at:

https://brainly.com/question/14284157

Write a switch statement that checks nextChoice. If 0, print "Rock". If 1, print "Paper". If 2, print "Scissors". For any other value, print "Unknown". End with newline.

Answers

Answer:

case 0:

           System.out.println("Rock");

           break;

       

        case 1:

           System.out.println("Paper");

           break;

       

        case 2:

           System.out.println("Scissors");

           break;

           

        default:

           System.out.println("Unknown");

           break;

       

     }

Explanation:

In this exercise we have to use the knowledge of computational language in python to describe a code, like this:

The code can be found in the attached image.

To make it easier the code can be found below as:

case 0:

          System.out.println("Rock");

          break;

case 1:

          System.out.println("Paper");

          break;

case 2:

          System.out.println("Scissors");

          break;

       default:

          System.out.println("Unknown");

          break;

    }

See more about python at brainly.com/question/26104476

You are asked by your supervisor to export NPS configuaration from a server. Your supervisor contacts you and tells you it is missing the log files. What must you do to provide your supervisor with the NPS log files?

Answers

Answer:

You must import the NPS configurations, then manually cnfigure the SQL Server Logging on the target machine.

Explanation:

The SQL Server Logging settings are not in anyway exported. If the SQL Server Logging was designed on the root machine, the a manually configure of SQL Server Logging has to be done on the target machine after the NPS configurations must have been imported.

Although administrator rights is needed at least to import and export NPS settings and configurations, while that isn’t the issue in this case. NPS configurations are moved to a XML file that is non-encrypted by default. There is no wizard or tool whatsoever to export or import the configuration files.

Other Questions
In a survey of 248 people, 156 are married, 70 are self-employed, and 25 percent of those who are married are self-employed. If a person is to be randomly selected from those surveyed, what is the probability that the person selected will be self-employed but not married? A twin study is conducted to examine the role of genetics and environment on the fondness of individuals for chocolate. Which of the following results would lead to the conclusion that genetic factors are important in the development of this trait?a. Twins who have lived together are more similar on the trait than twins who have lived apart.b. Twins who have lived apart are more similar on the trait than twins who have lived together.c. Identical twins are more similar on the trait than fraternal twins.d. Fraternal twins are more similar on the trait than identical twins What are two other forms to write the numbers 0.253 and 7.632? (2x3) as a fraction Use the graph to find the coordinates of each vertex intriangle ABCis the coordinate of Point A.is the coordinate of Point B.is the coordinate of Point C(0, -1)IntroDone Some highways have commuter or express pass lanes. During rush hour lanes on the highway move slowly or often are stop and go, but the express lanes continue to move at a faster pace. Express pass users pay for a transponder and monthly fees to have express lane access even with no other people in their cars. In this example, the drivers who purchase these express passes are probably __________.a. richer than drivers waiting in the longer commute lines on the freeway.b. more important than drivers waiting in the longer commute lines on the freeway.c. drivers who value speed and convenience more than those in the stop and go lanes and are willing to pay additional express pass fees for the option of avoiding traffic jams.d. experienced drivers that know that the best way to avoid commuter lines on the freeway is to leave home earlier to get to work. Where a compass points to in Hudson Bay Canada Which most simplified form of the law of conservation of energy describes the motion of the block as it slides on the floor from the bottom of the ramp to the moment it stops? Chase measured a line to be 8.9 inches long. If the actual length of the line is 9.5 inches, then what was the percent error of the measurement, to the nearest tenth of a percent? The first two steps in determining the solution set of the system of equations, y = x2 6x + 12 and y = 2x 4, algebraically are shown in the table.Which represents the solution(s) of this system of equations? (4, 4) (4, 12) (4, 4) and (4, 12) (4, 4) and (4, 12) Which shows one way to determine the factors of x^3+5x^2-6x-30 by grouping? Currently you purchase ten frozen pizza per month. You will graduate from college in December, and you will start a new (high-paying) job in January. You have no plans to purchase frozen pizzas in January. For you, frozen pizzas are a(n) Find the derivative of F(x)=-x^4+4x^3+ 70 for 0 1. How does the complete equity method, used to facilitate consolidation in subsequent years, differ from the equity method used for external reporting? A. The complete equity method adjusts for upstream and downstream unconfirmed profits, while the equity method used for external reporting does not make these adjustments. B. The complete equity method deducts unconfirmed profits on downstream sales to the extent of ownership interests, while the equity method used for external reporting deducts all unconfirmed profits on downstream sales. C. The complete equity method deducts unconfirmed profits on upstream sales to the extent of ownership interests, while the equity method used for external reporting deducts all unconfirmed profits on upstream sales. At work, Jenna always volunteers to help others on their projects. But, she really resents the extra work and constantly complains to her friends that she is doing everyone elses job. Jenna is not _____; she needs to be more self-aware of what she takes on. A small welding shop employs four welders and one secretary. A workers' compensation insurance policy charges a premium of $ 10.57 per $100 of gross wages for the welders and$ 1.31 per $100 of gross wages for the secretary. If each welder earns $ 37 comma 000 per year, and the secretary earns $ 24 comma 000 per year, what is the total annual premium for this insurance? Of the following members to the pilgrimage which has the highest social status What phrases can be used to describe the line representing the relationship between the number of balloons remaining and the number of hats created? Select three options What is 2x(6-7)+(8x2) Write the decimal equivalent of each fraction 1/2