1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
liq [111]
4 years ago
11

Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other sou

rce. Try to be creative with your examples to demonstrate that you invented them yourself.
Example 1: Define a function that takes an argument. Call the function. Identify what code is the argument and what code is the parameter.

Example 2: Call your function from Example 1 three times with different kinds of arguments: a value, a variable, and an expression. Identify which kind of argument is which.

Example 3: Create a function with a local variable. Show what happens when you try to use that variable outside the function. Explain the results.

Example 4: Create a function that takes an argument. Give the function parameter a unique name. Show what happens when you try to use that parameter name outside the function. Explain the results.

Example 5: Show what happens when a variable defined outside a function has the same name as a local variable inside a function. Explain what happens to the value of each variable as the program runs.
Computers and Technology
1 answer:
natulia [17]4 years ago
6 0
Ssfhooiyfbjkoyfvhkodd
You might be interested in
Function Name: d2x Parameters: int, int Returns: string Description: Write function, d2x, that takes as input a nonnegative inte
Marina CMI [18]

Answer:

I am writing a Python program. Let me know if you want the program in some other programming language.

#definition of function d2x which takes two parameters v: which is a non #negative integer and x which is an integer between 2 and 9. this method #returns string of digits that represents the base-x representation of v

def d2x(v,x):

   remainder = v%x  

   if v<=1:

       return str(v)

   else:

       return str(d2x(v//x,x)) + str(remainder)

 

v= int(input("Enter a non negative integer: "))

x= int(input("Enter an integer between 2 and 9: "))

print(d2x(v,x))

Explanation:

I will explain the code line by line.

def d2x(v,x) This is the definition of function d2x which takes two parameters v: which is a non negative integer and x which is an integer between 2 and 9. This method returns string of digits that represents the base-x representation of v.

Now lets take an example to understand the working of this function.

Suppose the value of v = 10 and x = 2.

remainder = v%x  takes the mod of v and x which returns the remainder of the division of v by x. So v%x = 10 % 2 = 0. So remainder = 0.

if v<=1 This if condition checks if the value of v is less than or equal to 1. This is false because v=10 and 10 is greater than 1. If v is 1 or less than return str(v)  will return the value of v as it is i.e. 10.

Since the IF condition is false so the else part will execute which has the following statement: return str(d2x(v//x,x)) + str(remainder)

This calls the d2x function recursively. Here v is divided by x successively until the quotient of v divided by x is 0. On each successive division, the remainder is the new most significant digit. In v//x, the double slash is called floor division or integer division which we use as both v and x are integers. So using recursion the above statement becomes:

str(d2x(v//x,x)) + str(remainder)

str(d2x(10//2,2) + str(0)

d2x(5,2) + (0)

Now d2x will again be called recursively to perform the division and this successive division continues until quotient of v divided by x is 0. Here str() method is used returns the result in the form of string.  So v%x is the number which is added to the end of resultant number. v//x is the recursive portion which keeps using the answer of the previous binary number. This means 10 in base 2 calls convert(5,2), then adds 0 at the end. So when v//x=5 and v%x=0 So the answer is 1010.

At the end v= int(input("Enter a non negative integer: "))

x= int(input("Enter an integer between 2 and 9: "))  these two statement wills take integer input from user and print(d2x(v,x)) calls d2x method and print the result.

6 0
3 years ago
What are two specific Netstumbler features that are related to cybersecurity? Name one feature that is related to improving cybe
NikAS [45]

The feature that can improve cybersecurity is the detection of interferences, and the one that can be used by hackers is checking the configuration of networks.

Netstumbler is a program used to identify surround wireless networks. This program is mainly available for Window systems and includes the following features:

  • Detecting wireless networks.
  • Detecting interferences.
  • Checking the configuration of networks.

These features have both a positive and a negative side as they can be used to increase cybersecurity, which is positive, but they can also be used by hackers to attack networks and the devices in them.

One positive feature is the detection of interferences because this can be used to detect possible external or threatening networks. On the other hand, checking the configuration can be a negative feature because hackers can use this information to enter and hack the networks.

Learn more in:  brainly.com/question/17021829

4 0
3 years ago
Which type of visual aid should students use to track small changes over time?
xenn [34]
Line graphs are used to graph change in time
7 0
3 years ago
Read 2 more answers
Does learning swift is hard? more than android?
ladessa [460]
No it is not. it's quite simple when you get the hang of it
4 0
4 years ago
Create a recursive method, a method that calls itself, that returns true or false depending on whether or not a given string is
ICE Princess25 [194]

Answer:

public class CheckPalindrome{

public static boolean IsPalindrome(String str){

if(str.Length<1)

{

return true;

}

else

{

if(str[0]!=str[str.length-1])

return false;

else

return IsPalindrome(str.substring(1,str.Length-2));

}

}

public static void main(string args[])

{

//console.write("checking palindromes");

string input;

boolean flag;

input=Console.ReadLine();

flag= IsPalindrome(input);

if(flag)

{

Console.WriteLine("Received"+input+"is indeed palindrome");

}

else

{

Console.WriteLine("received"+input+"is not a palindrome");

}

}

Explanation:

6 0
3 years ago
Other questions:
  • Using the college registration example from section 6.7.3 as a starting point, do the following:
    14·1 answer
  • An example of a __________________ in the United States are computer hackers, whose members engage in actions that subvert autho
    11·1 answer
  • What is the value of the result after the following statement is executed? int result = 2 + 3 + 4 ;
    7·1 answer
  • 100 in hexadecimal then. binary
    11·1 answer
  • Data are sent through a network on bundles called _______. select one:
    8·2 answers
  • Name the written test a potential driver must pass and list the minimum required score to earn a learner’s license.
    8·2 answers
  • 1. How many bits would you need to address a 2M × 32 memory if:
    8·1 answer
  • Which input and output pair is correct for a bicycle?
    12·1 answer
  • How do you get a blank business card template in word?
    15·1 answer
  • Choose the 3 Points in good story telling
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!