Questions
I don't know which one is wrong. Can you please check. Thank you QUESTION 1 In...

I don't know which one is wrong. Can you please check.

Thank you

QUESTION 1

  1. In the following code, how many and which functions have been defined/declared?

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    1 function: powerNum

    1 function: powerNum

    3 functions: powerNum, and main is defined/declared twice.

    2 functions: powerNum and main

QUESTION 2

  1. In the following code, which of the variable(s) is (are) considered as global variable(s):

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    p and power

    pNum

    p

    power

    n

QUESTION 3

  1. In the following code, which line of code is returning the value for function powerNum?

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    def powerNum(power):

    print ("Power of the number you entered is", powerNum (p))

    return pNum

    pNum = n ** power

QUESTION 4

  1. In the following code, which of the variable(s) is (are) considered as parameter variable(s):

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    n

    pNum

    p and power

    p

    power

QUESTION 5

  1. After learning about the issues with global variables, Amita took the old code with global variables in cell A and re-wrote without global variables. Based on the partial code done in the cell below, what changes, if any, need to be made to the code in cell-B below?

    cell-A: Old code with global variables cell-B: Partial new code without global variables

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    def powerNum(power):

    pNum = n ** power

    return pNum

    def main():

    n = int(input("Enter a number whose power you want to calculate: "))

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    We need to just change powerNum function to accept two parameters: one for power value and one for the number as below

    def powerNum(power, n):

    No changes need to be made to main or powerNum functions

    Yes, powerNum should now be defined with two parameters: one for power value and one for the number as below

    def powerNum(power, n):

    Also we will need to change how the function is called in main function as below:

    powerNum(p,n)

    We need to just pass the additional argument when the powerNum function is called in main function as below:

    powerNum(p,n)

QUESTION 6

  1. In the following code, which line of code is calling or invoking function powerNum?

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    return pNum

    def powerNum(power):

    pNum = n ** power

    print ("Power of the number you entered is", powerNum (p))

QUESTION 7

  1. In the following code, which line of code is defining or declaring function powerNum?

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    def powerNum(power):

    return pNum

    pNum = n ** power

    print ("Power of the number you entered is", powerNum (p))

QUESTION 8

  1. In the following code, which of the variable(s) is(are) considered as argument(s):

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    p and power

    n

    power

    p

    pNum

QUESTION 9

  1. In python, how can you pass arguments to a function?

    by keyword arguments only and can be in any order

    default is by position but you can also pass by keyword arguments as in the case below:

    show_interest (rate=0.01, periods=10, principal=10000.0)

    by position only and they must be passed in the same order in which they are defined in the function header

    by position only and they can be passed in any order irrespective of how are they are defined

QUESTION 10

  1. In the following code, in which order do the lines of code get executed?

    def powerNum(power):

    pNum = n ** power

    return pNum

    n = int(input("Enter a number whose power you want to calculate: "))

    def main():

    p = int(input("Enter the power number: "))

    print ("Power of the number you entered is", powerNum (p))

    main()

    getting input n from the user >>  calling main function >> calling powerNum function >> ending in powerNum function

    calling powerNum function >>  getting input n from the user >>  calling main function

    getting input n from the user >> calling main function >> calling powerNum function >> returning back to main function from powerNum function

In: Computer Science

C Programming Please write a single function and not the whole program Can you please provide...

C Programming Please write a single function and not the whole program

Can you please provide comments and explanations for all questions. Thank you

Write a single function for the following:

void split_date(int day_of_year, int year, int *month, int *day);

            day_of_year is an integer between 1 and 366, specifying a particular day within the year

designated by the parameter year. Month and day point to variables in which the function
will store the equivalent month (1 – 12) and day within the month (1 – 31)

The question is trying to ask you to write a single function in C that takes a day of the year (1-366) and calculates which month and which day of the month corresponds to that day of in the month. So a day of the year of let's 15 would return 1 (for the month - January) and 15 for the day of the month. The second parameter (year) is needed because leap years have 366 days and non-leap years have 365 days.

In: Computer Science

SQL is our language for relational databases - do you think it's an adequate "language" for...

SQL is our language for relational databases - do you think it's an adequate "language" for database creation and manipulation?

In: Computer Science

Discuss the use of artificial intelligence in automation of tasks in accounting giving 3 pertinent examples....

Discuss the use of artificial intelligence in automation of tasks in accounting giving 3

pertinent examples. Need to be 520 word

In: Computer Science

A sequence of integers x1,x2,...,xn is unimodal if for some 1 ≤ i ≤ n we...

A sequence of integers x1,x2,...,xn is unimodal if for some 1 ≤ i ≤ n we have x1 < x2 < ... < xi and xi > xi+1 > ... > xn. Find the maximum element in a unimodal sequence of integers x1, x2, . . . , xn. The running time should be O(log n). Show that your algorithm meets the bound.

In: Computer Science

Consider the following scenario and design a C++ program using an output stream file: A person...

Consider the following scenario and design a C++ program using an output stream file: A person invests $1,000 on a savings account yielding 5% interest. Assuming that all the interest is left on deposit, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula to determine the amounts: a = p (1 + r)n where p is the original amount invested (i.e., the principal) r is the annual interest rate (e.g., use 0.05 for 5%)f n is the number of years a is the amount on deposit at the end of the nth year. Your program must have an output file to display your results.

In: Computer Science

Under System requirement provide a detail overall description, product perspective, Memory Constraint, user interface, Site adaptation...

Under System requirement provide a detail overall description, product perspective, Memory Constraint, user interface, Site adaptation Requirements and Operations of building a HBCU Database Hub/Center.

In: Computer Science

python programming. Write a program that prompts the user to enter an integer from 0 to...

python programming.

Write a program that prompts the user to enter an integer from 0 to 9. The program will check if the input is a positive integer. It displays the correct answer and shows the guess is correct or not. The demos are shown as following.(Hint:1. Use a random math function 2. Use str.isdigit() to check the input)

In: Computer Science

Using Python programming, make a form that allows user to login to a modest web application...

Using Python programming, make a form that allows user to login to a modest web application that has a password and username with a file that has validated user. Once logged in, a formal greeting and the choice to change password should be available. The password should be strong(NIST SP 800-63B). All failed logins should be logged w/ date and Time. (Ex. 6 failed logins in 20 min dated 12 Jan 2020.

In: Computer Science

Use C to Write a program that takes the array reverse_me and reverses the order of...

Use C to Write a program that takes the array reverse_me and reverses the order of the elements (i.e., the first element and the last element are swapped, the second element and the second-to-last element are swapped, etc.). Store the reversed array in reversed_arr. Finally, print out the reversed array as a string.

In: Computer Science

PLEASE USE ONLY FLOWGRITHM!!! Design a modular program that accepts as input 20 numbers between 0...

PLEASE USE ONLY FLOWGRITHM!!!

Design a modular program that accepts as input 20 numbers between 0 and 100 (including 0 and 100). The program should store the numbers in an array and then display the following information:

The lowest number in the array

The highest number in the array

The total of the numbers in the array

The average of the numbers in the array

Your program should consist of the following:

Module main. Accepts input of numbers and assigns them to an array. The array is traversed in order to find the highest number, lowest number, total and average of the numbers.

Module showStats. Displays the highest number, lowest number, total and average of the numbers.

Please Show the Flowgorithm used!!!

In: Computer Science

Please submit 1) the source code (.java file), and 2) the screenshot of running results of...

Please submit
1) the source code (.java file), and
2) the screenshot of running results of each question.

  1. (Factorials) Write an application that calculates the factorial of 20, and display the results. Note: 1) The factorial of a positive integer n (written n!) is equal to the product of the positive integers from 1 to n. 2) Use type long.

  2. (Largest and Smallest Integers) Write an application that reads five integers and determines and prints the largest and smallest integers in the group. Use for loop.

In: Computer Science

Use a swift language in xcode software for the following code? 20 pts Create a class...

Use a swift language in xcode software for the following code?

20 pts Create a class called Polygon, this class will have:

a. Properties:

i. Number of sides

ii. Interior angles

b. Method

i. sides(), this will print to the console how many sides the polygon has

ii. interiorAngle(), this will calculate the interior angles and set it to the interior angles property

Create another class named Triangle that inherits from Polygon. This class will have to:

a. Properties:

i. Area

ii. Side length

b. Method i. calculateArea

In: Computer Science

write Java program has two classes ,( using Inheritance ) first class set ( id ,...

write Java program has two classes ,( using Inheritance )

first class set ( id , name ) and method output

second class ( id , name , Mark 1 , Mark 2 , Mark 3 )

method total , average , grade , results ( if the student pass or not ) , and output method

In: Computer Science

Use Java A pet shop wants to give a discount to its clients if they buy...

Use Java

A pet shop wants to give a discount to its clients if they buy one or more pets and at least five other items. The discount is equal to 20 percent of the cost of the other items, but not the pets.

Use a class Item to describe an item, with any needed methods and a constructor

public Item(double price, boolean isPet, int quantity)

An invoice holds a collection of Item objects; use an array or array list to store them. In the Invoice class, implement methods

public void add(Item anItem)
public double getDiscount()

Write a program that prompts a cashier to enter each price and quantity, and then a Y for a pet or N for another item. Use a price of –1 as a sentinel (i.e. -1 means all values have been entered). In the loop, call the addmethod; after the loop, call the getDiscount method and display the returned value.

In: Computer Science