Will the Python code below print something? And will it terminate?
def print_n(s, n):
if n > 0:
print(s)
print_n(s, n-1)
return n
n = 3
while print_n("hi", n):
print_n("there!", n)
n = 0
a. no and no
b. yes and no
c. no and yes
d. yes and yes
e. syntax error

Answers

Answer 1

Answer:

Yes and Yes

Explanation:

When programs are written without indentation; it becomes a problem to read;

I'll rewrite your program as follows:

def print_n(s, n):  

   if n > 0:  

       print(s)  

       print_n(s, n-1)  

   return n  

n = 3  

while print_n("hi", n):  

   print_n("there!", n)  

   n = 0

Using the above as a point of reference,

Yes, the program will run and Yes, it'll terminate;

Because n is initialized to 3 at line 6 (where the main starts);

The following is passed to the function; s = "hi" and n=3

This prints "hi", three times

s = "there" and n=3 is then passed to the function print_n, afterwards;

The function then prints "there" three times

Then, the program terminates


Related Questions

An employer plans to pay bonus to each of his employees. Those earning Rs. 2000 or above are to be paid 10 percent of their salary and those earning less than 2000 are to be paid Rs. 200. The input record contains employee number, name and salary of an employee. The output should be employee name and their bonus. Write pseudo code algorithm to process the requirement.

Answers

Answer:

vfg

Explanation:

Which of the following BEST describes an inside attacker?
An agent who uses their technical knowledge to bypass security.
An attacker with lots of resources and money at their disposal.
A good guy who tries to help a company see their vulnerabilities.
An unintentional threat actor. This is the most common threat.​

Answers

The inside attacker should be a non-intentional threat actor that represents the most common threat.

The following information related to the inside attacker is:

It is introduced by the internal user that have authorization for using the system i.e. attacked.It could be intentional or an accidental.So it can be non-intentional threat.

Therefore we can conclude that The inside attacker should be a non-intentional threat actor that represents the most common threat.

Learn more about the threat here: brainly.com/question/3275422

Hello, I am having trouble adding a txt file into a array, so I can pop it off for a postfix problem I have uploaded what I have so far. I need help please

Answers

Answer:

#include <stack>

#include<iostream>

#include<fstream> // to read imformation from files

#include<string>

using namespace std;

int main() {

   stack<string> data;

   ifstream inFile("postfix.txt");

   string content;

   if (!inFile) {

       cout << "Unable to open file" << endl;

       exit(1); // terminate with error

   }

   while (getline(inFile, content)) {

       data.push(content);

   }

   inFile.close();

   return 0;

}

Explanation:

You were very close. Use the standard <stack> STL library, and make sure the stack elements are of the same type as what you're trying to add, i.e., std::string.

why you think Operating System is pivotal in teaching and learning.

Answers

Answer:

An Operating System is pivotal in teaching and learning because:

1. It enables computer users to communicate with the hardware.

2. To run any computer programme successfully, the Operating System is basic.

3. It provides a smooth interface for teachers to use video conferencing or other conferencing systems in teaching their students.

4. The OS enables the launching of other learning packages on a computer system.

5. Students can install learning apps on their systems with the help of the OS.

Explanation:

An Operating System is a software which brings about easy communication with the hardware and enablea other programs to run on the computer easily. It provides basic functionality in systems were they are installed.

Consider a network that is a rooted tree, with the root as its source, the leaves as its sinks, and all the edges directed along the paths from the root to the leaves. Design an efficient algorithm for finding a maximum flow in such a network. What is the time efficiency of your algorithm

Answers

Answer:

please mark me brainlist

Explanation:

The bank offers the following types of accounts to its customers: saving accounts, checking accounts and money market accounts. Customers are allowed to deposit money into an account (thereby increasing its balance), withdraw money from an account (thereby decreasing its balance) and earn interest on the account. Each account has an interest rate

Assume that you will write the code for an application that will calculate the amount of interest earned for a bank account.

a. Identify the potential classes in this problem domain be list all the nouns
b. Refine the list to include only the necessary class names for this problem
c. Identify the responsibilities of the class or classes.

Answers

C is the correct answer

Describe how tuples can be useful with loops over lists and dictionaries,
and give Python code examples.
Create your own code examples. Do not copy them from the textbook or any other source.
Your descriptions and examples should include the following: the zip function, the enumerate function, and the items method.

Answers

Answer:

what is computer

what is simple machine

what is output device

You are the network administrator for your company. A user reports that he cannot access network resources from his computer. He was able to access the resources yesterday. While troubleshooting his computer, you find that his computer is issued an Automatic Private IP Addressing (APIPA) address. All the network equipment in the user's computer is functioning properly because you are able to access the user's computer from a remote computer. What is most likely the problem

Answers

Answer:

the issued Automatic Private IP Addressing (APIPA) address.

Explanation:

Since we are told that the user was able to access the network resources yesterday, and all the network equipment in the user's computer is functioning properly, there is a very high possibility that because the user's computer has been issued an Automatic Private IP Addressing (APIPA) address, it affected his computer's ability to connect to a public network.

This is the case because private network IP addresses are known to prevent inflow and outflow of data onto public networks.

Your system is infected with a virus that can modify signature each time it is executed to fool antivirus software. Which type of virus is this?

Answers

Answer:Polymorphic Virus

Explanation:

Malware that can change its signature each time is polymorphic

Which one is the result of the ouWhen you move a file to the Recycle Bin, it will be immediately deleted from your computer.

A. True

B. Fals

Answers

Answer:

B => false

Explanation:

it just keep it on recycle bin => not being removed

False

Explaination :

The deleted file will stay in Recycle Bin for a short period of time before it's permanently deleted from your computer

Use the Excel worksheet data below to solve the following questions.
H
1
J
5
6
7
7
8
5
do 00
9
10
A
12
8
11
9
T
9
3
4
w
9
11
12
13
14
15
17
15
7
M
column H 2n cicle de genula
ingles are creation CHF HIM)
2. Write the function that would find the average cells in
(2 marks)
3. Write the function that would find the total values in column J (2 marks)
4. Write the function that would count all values.
(2 marks)
5. Write the function that would count the number of
occurrences of 9 in the entire range
(3 marks)

Answers

Answer:

I love Microsoft Excel!

Explanation:

2 - The function that would find the average of a particular range is =AVERAGE(). This is used to find the average of something by calculating the arithmetic mean (or just "mean").

3 - The function that would find the total values within a particular range---or in this case, Column J---you would use the =SUM() function. This will add up all of the values in the range you selected. An example could be that Column X has the values of 5, 6, 12, 45, 3. =SUM(X1:X5) = 71.

4 - The function that would count all values is defined as =COUNT(). An example would be =COUNT(A1:A10).

5 - The function that would count the number of occurrences within a particular range is defined as =COUNTIF(). Within the parentheses, you would put the range of data that you are working with. Then, in quotations, you would put the name or value that you are trying to find.

In your case, it would be =COUNTIF(range,"9") ((I put range in there since I do not know what your range is as it is not defined within the context of this question))

how do you run a function in python?

Answers

You can call a Python function like so: function(parameters).

Example:

Define function add:
def add(x,y):
return x+y

Call function:
add(3,7) -> 10

Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:


"Hello! I'm Miley! Nice to meet you!"

#include

#include

using namespace std;

void MakeSentenceExcited(char* sentenceText) {


/* Your solution goes here */

}


int main() {

const int TEST_STR_SIZE = 50;

char testStr[TEST_STR_SIZE];

strcpy(testStr, "Hello. I'm Miley. Nice to meet you.");

MakeSentenceExcited(testStr);


cout << testStr << endl;


return 0;


}

Answers

Answer:

Here is the complete function:

void MakeSentenceExcited(char* sentenceText) {  // function that takes the text as parameter and replaces any period by an exclamation point in that text

int size = strlen(sentenceText);  //returns the length of sentenceText string and assigns it to size variable

char * ptr;  // character type pointer ptr

ptr = sentenceText;  // ptr points to the sentenceText string

for (int i=0; i<size; i++){  //iterates through the sentenceText string using i as an index

    if (sentenceText[i]=='.'){  // if the character at i-th index of sentenceText is a period

        sentenceText[i]='!'; } } } //places exclamation mark when it finds a period at i-th index of sentenceText

Explanation:

The program works as follows:

Suppose we have the string:

sentenceText = "Hello. I'm Miley. Nice to meet you."

The MakeSentenceExcited method takes this sentenceText as parameter

int size = strlen(sentenceText) this returns the length of sentenceText

The size of sentenceText is 35 as this string contains 35 characters

size =  35

Then a pointer ptr is declared which is set to point to sentenceText

for (int i=0; i<size; i++) loop works as follows:    

1st iteration:

i=0

i<size is true because i=0 and size = 35 so 0<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[0]=='.')

The first element of sentenceText is H

H is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 1

2nd iteration:

i=1

i<size is true because i=1 and size = 35 so 1<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[1]=='.')

This is the second element of sentenceText i.e. e

e is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 2

So at each iteration the if condition checks if the character at i-th index of string sentenceText is a period.

Now lets see a case where the element at i-th index is a period:

6th iteration:

i=5

i<size is true because i=5 and size = 35 so 5<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[5]=='.')

This is the character at 5th index of sentenceText i.e. "."

So the if condition evaluates to true and the statement inside if part executes:

sentenceText[i]='!'; statement becomes:

sentenceText[5]='!'; this means that the character at 5th position of sentenceText string is assigned an exclamation mark.

So from above 6 iterations the result is:

Hello!

This loop continues to execute until all the characters of sentenceText are checked and when the value of i gets greater than or equal to the length of sentenceText then the loop breaks.

The screenshot of the program along with its output is attached.

consider l= 5 ,r= 11. you must determine the sum of the values of the function in the range L to R . you have to calculate sum = lrf(x) in python coding

Answers

def summation (num1, num2):

i = 0

for x in range (num1 : num2 + 1):

i += x

return i

print ( summation(l, r))

Which is the first computer brought in nepal for the census of 2028 B.S​

Answers

Answer:

The first computer brought in Nepal was IBM 1401 which was brought by the Nepal government in lease (1 lakh 25 thousands per month) for the population census of 1972 AD (2028 BS). It took 1 year 7 months and 15 days to complete census of 1crore 12.5 lakhs population.

Is it appropriate to send an email and call the individual the same day to ask if they have received your email?

Answers

Answer:

It depends. (OPINION)

Explanation:

If this is an important email, and it REALLY had to be sent the day of, then yes, it may be appropriate to call the day of. However, if you procrastinated until the last day and are really worried; well; that's your fault. At least wait a day and give the receiver some time to process; they could be really busy. At least that's how I view it.

The program to check the highEst of n numbercan be done by ......,..

Answers

Answer: Given an array of numbers, arrange them in a way that yields the largest value. For example, if the given numbers are {54, 546, 548, 60}, the arrangement 6054854654 gives the largest value. And if the given numbers are {1, 34, 3, 98, 9, 76, 45, 4}, then the arrangement 998764543431 gives the largest value.

Explanation: If you need more help follow me on istagram at dr.darrien

-thank you

Alice and Bob are unknown to each other. Alice wants to send an encrypted message to Bob. So it chooses a KDC which is known to both Alice and Bob (protocol in page 338). Alice and KDC have A5 (hexa) as a shared key. Bob and KDC have 4B (hexa) as a shared key. Alice sends a request to KDC to generate a session key so it can communicate with Bob. KDC generates 56(hexa) as a session key. Alice intends to send 13 (hexa) as a message to Bob. For simplicity assume that the encryption and decryption operations are simply XOR operation of the key with the message. Answer the following.
1. What information does KDC send to Alice? Show as hex characters.
2. What information does Alice send to Bob? Show as hexa characters.
3. What message does Bob retrieve after decryption? Show as hexa characters.

Answers

3. ¿Qué mensaje recupera Bob después del descifrado? Mostrar como caracteres hexadecimales.

Respuesta: la clave con el mensaje :

list 2 forms of computer output​

Answers

Audio, visual, and hard copy media

Answer:

Soft copy like audio

Hard copy e.g printouts

Explanation:

What are some of the major issues with geotagging? What concerns you the most?

Answers

Answer:

Major issues with geotagging include the ability to pinpoint the exact location where a photo was taken, which raises privacy concerns.

What concerns me the most is when a geotag of an unsuspecting victim's location falls into the wrong hands.

Explanation:

Geotag -  A geographical tag that can attach to SMS text messages, media such as photos and images, etc. The Geotag is measured in the longitude and latitude at which the image or text message took place.

what makes''emerging technologies'' happen and what impact will they have on individuals,society,and environment

Answers

Answer:

Are characterized by radical novelty

Explanation:

Example, intelligent enterprises are reimaging and reinventing the way they do bussines

Maintaining public libraries is a waste of money since computer technology can replace their functions. Do you agree or disagree?

Answers

Answer:

I totally do not agree that maintaining public library is a waste of money

Explanation:

Most library are now advancing in terms of service delivery and public

libraries are no exception as libraries are now incorporating E- platforms/E- libraries, Audio visuals, where anyone can learn or borrow materials electronically.

         Furthermore, not everyone can own a computer set to so that public libraries are even relevant to the majorities who can afford a computer set.

Also a library especially the public library is a place where people can meet and socialize to the end we even make friends at the public library more effectively than the online library can make(if they can).

In summary the pros of physical public libraries can not be over emphasized.

 

CHALLENGE ACTIVITY 3.7.2: Type casting: Reading and adding values.
Assign totalowls with the sum of num_owls A and num_owls_B.
Sample output with inputs: 34
Number of owls: 7
1. total_owls -
2.
3. num_owls A - input
4. num_owls_B - input
5.
6. " Your solution goes here
7.
8. print("Number of owls:', total_owls)

Answers

Answer:

total_owls = 0

num_owls_A = int(input())

num_owls_B = int(input())

total_owls = num_owls_A + num_owls_B

print("Number of owls:", total_owls)

Explanation:

Initialize the  total_owls as 0

Ask the user to enter num_owls_A and num_owls_B, convert the input to int

Sum the num_owls_A and num_owls_B and set it to the total_owls

Print the total_owls

avg_owls=0.0

num_owls_zooA = int(input())

num_owls_zooB = int(input())

num_owls_zooC = int(input())

num_zoos = 3

avg_owls = (num_owls_zooA + num_owls_zooB + num_owls_zooC) / num_zoos

print('Average owls per zoo:', int(avg_owls))

There is a problem while you are trying the calculate the average owls per zoo.

As you may know, in order to calculate the average, you need to get the total number of owls in all the zoos, then divide it to the number of zoos. That is why you need to sum num_owls_zooA + num_owls_zooB + num_owls_zooC and divide the result by num_zoos

Be aware that the average is printed as integer value. That is why you need to cast the avg_owls to an int as int(avg_owls)

Learn more about integer value on:

https://brainly.com/question/31945383

#SPJ6

Define a function group-by-nondecreasing, which takes in a stream of numbers and outputs a stream of lists, which overall has the same numbers in the same order, but grouped into segments that are non-decreasing.

Answers

Answer:

def group_by_nondecreasing( *args ) :

     num_list = [arg for arg in args]

     sorted_numlist = sorted( num_list )

     list_stream = [ sorted_numlist, sorted_numlist, sorted_numlist ]

     return list_stream

Explanation:

This python function has the ability to accept multiple and varying amount of arguments. the list comprehension shorten the logical for statement to generate a list of numbers, sorts the list in ascending order by default and duplicates the list in another list.

Solve using Matlab the problems:

One using the permutation of n objects formula

One using the permutation of r objects out of n objects

you can make up your own questions.


Help me please

Answers

Answer:

Explanation:

% Clears variables and screen

clear; clc

% Asks user for input

n = input('Total number of objects: ');

r = input('Size of subgroup: ');

% Computes and displays permutation according to basic formulas

p = 1;

for i = n - r + 1 : n

   p = p*i;

end

str1 = [num2str(p) ' permutations'];

disp(str1)

% Computes and displays combinations according to basic formulas

str2 = [num2str(p/factorial(r)) ' combinations'];

disp(str2)

=================================================================================

Example:

How many permutations and combinations can be made of the 15 alphabets, taking four at a time?

The answer is:

32760 permutations

1365 combinations

Assume the existence of a Phone class. Define a derived class, CameraPhone that contains two data members: an integer named, imageSize, representing the size in megabytes of each picture, and an integer named memorySize, representing the number of megabytes in the camera's memory. There is a constructor that accepts two integer parameters corresponding to the above two data members and which are used to initialize the respective data members. There is also a function named numPictures that returns (as an integer) the number of pictures the camera's memory can hold.

Answers

#include <iostream>

using namespace std;

class CameraPhone:Phone{

int imageSize,memorySize;

public:

CameraPhone(int image_size,int memory_size):imageSize(image_size),memorySize(memory_size){}

int numPictures(){

return memorySize-imageSize;

}

}

int main(){}

Here is the code for the derived class, CameraPhone:

class Phone:

 def __init__(self, brand, model, price):    self.brand = brand    self.model = model    self.price = price

class CameraPhone(Phone):

 def __init__(self, brand, model, price, imageSize, memorySize):    super().__init__(brand, model, price)    self.imageSize = imageSize    self.memorySize = memorySize

 def numPictures(self):

   return self.memorySize // self.imageSize

What are the derived class?

This code defines a derived class, CameraPhone, that inherits from the Phone class. The CameraPhone class has two additional data members: imageSize and memorySize. The constructor for the CameraPhone class takes two additional parameters corresponding to these data members. The numPictures() function returns the number of pictures that the camera's memory can hold.

Here is an example of how to use the CameraPhone class:

phone = CameraPhone("Apple", "iPhone 13 Pro", 1000, 10, 100)

print(phone.numPictures())

# Output: 10

This code will print the number of pictures that the camera's memory can hold, which is 10 in this case.

Find out more on derived class here: https://brainly.com/question/31942927

#SPJ2

Speeding is one of the most prevalent factors contributing to traffic crashes.
A. TRUE
B. FALSE

Answers

Answer:

A true

Explanation:

Speeding leads to an increase in the degree of crash severity, possibly resulting in more fatalities or injuries. More damage is caused to the vehicles involved at higher speeds, increasing likelihood vehicle will not be drivable after a crash.

The statement "Speeding is one of the most prevalent factors contributing to traffic crashes" is true.

What is speeding?

Speeding causes crashes to be more severe, which could lead to more fatalities or injuries. Higher speeds result in more damage to the involved vehicles, increasing the risk that the vehicle won't be drivable following a collision. There are many accidents increasing because of high speed.

The term "speeding" refers to moving or traveling swiftly. He paid a penalty for speeding. For many American drivers, speeding has become the standard, whether it is going over the posted speed limit, driving too quickly for the road conditions, or racing. Nationwide, speeding contributes to road fatalities.

Therefore, the statement is true.

To learn more about speeding, refer to the link:

https://brainly.com/question/15297960

#SPJ2

explain computer coding in an understandable manner​

Answers

Answer:

Coding is simply how we communicate with computers. Code tells a computer what actions to take, and writing code is like creating a set of instructions

Explanation:

Computer coding empowers kids to not only consume digital media and technology, but to create it. Instead of simply playing videogame or envision what their own website, or app might look like and they'll have the outlet for the expression

"The fact that we could create and manipulate an Account object without knowing its implementation details is called"

Answers

Answer:

Abstraction

Explanation: Abstraction is a software engineer terminology that has been found to be very effective and efficient especially as it relates to object-oriented computer programming. It has helped software engineers and other computer experts to effectively manage account objects without having a knowledge of the details with regards to the Implementation process of that account object.

what are three ways to add receipts to quick books on line receipt capture?

Answers

Answer:

1) Forward the receipt by email to a special receipt capture email

2) You can scan, or take a picture of the receipt and upload it using the QuickBooks mobile app.

3) You can also drag and drop the image, or upload it into QuickBooks Online receipt center.

Explanation:

1) Th first process is simply done using the email address

2) On the app, tap the Menu bar with icon ≡.  Next, tap Receipt snap., and then

tap on the Receipt Camera. Yo can then snap a photo of your receipt, and tap on 'Use this photo.' Tap on done.

3) This method can be done by simply navigating on the company's website.

Other Questions
She would have passed if she _____________ hard . ( studies, had studied, studied) How do I solve 3(x+1)=5(x2)+7? which of the following is a quotient of the rational expressions shown here? Which is the exponential form of log9 5 = y What is a hyperbole comparing a cloud and pillow Al wonders if adding salt to water will affect how long it takes the water tofreeze. Al thinks that salt water will freeze more quickly than fresh water.He decides to check his hypothesis by conducting an experiment. Al takestwo ice trays and fills one with distilled water and the other with distilledwater that has two tablespoons of salt added. He makes sure he putsexactly the same amount of water in each ice tray. Al takes the trays andputs them side by side in the freezer. Al checks the ice trays every 10minutes to see if the water in each tray has begun to freeze. Al finds thatafter 20 minutes the water in the ice tray without the salt has started toform ice, while the ice tray with the salt water is still completely liquid.Ku If you add a solution of NaOH to a solution of HCO, two reactions occur, one after the other. Write the chemical equations for these two reactions. (Hint: NaOH dissociate into Na+ and OH-, and the hydroxide ion is the actual base). 8.9 x 10^3 in standard notation Which of the following best describes a similarity between Thomas Hobbesand Jean-Jacques Rousseau? If f(x)=-2x find x= -1A.-3B.-2C.2D.0 Answer this will give 10 points Find the area. Round to the nearest tenth.6 in.5 in.9 in.in. what positive changes have occurred on the earth the speaker visit heeelllpppppppppppppppp The shape on the left is translated to the shape on the right which statement about transformation is true? 4. Given the following pattern of shapes, choose the mathematical expression showing thchanges for each iteration if b is the number of boxes in the previous iterationa) b + 1b) b + 2c) 6-1d) 6-2 what things about our culture you would like to keep the following generation and what things you would like to get red off to remove from our culture ?? Quickly please Transistor circuits are sometimes referred to as switching circuits - Why is this? what is the answer and how do you solve it .please help Which of these is NOT a biological contaminant?