Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. 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

Answers

Answer 1

Example 1:
def greet(name):

 print("Hello,", name)

greet("John")


In this example, the function greet takes one argument, which is the variable name. When we call the function and pass in the argument "John", the function prints out Hello, John. The code "John" is the argument, and name is the parameter.

Example 2:
def greet(name):

 print("Hello,", name)

greet("John")

greet("Mary")

x = "Alice"

greet(x)

greet("Hi " + x)

In this example, we call the function greet three times with different kinds of arguments. "John" and "Mary" are values, x is a variable, and "Hi " + x is an expression.

Example 3:

def some_function():

 x = 5

print(x)


In this example, we define a function some_function that has a local variable x. When we try to print out the value of x outside of the function, we get a NameError because x is not defined in that scope.

Example 4:

def greet(name):

 print("Hello,", name)

greet("John")

print(name)


In this example, we define a function greet that takes an argument name. When we try to print out the value of name outside of the function, we get a NameError because name is a local variable that only exists within the scope of the greet function.

Example 5:

x = 10

def some_function():

 x = 5

 print("Inside function:", x)

some_function()

print("Outside function:", x)


In this example, we define a global variable x and a function some_function that has a local variable x. When we call some_function, it prints out the value of x as 5, which is the value of the local variable. When we print out the value of x outside of the function, it prints out 10, which is the value of the global variable. The local variable x inside the function and the global variable x outside the function are different variables with different values.

Answer 2

In this code, we first define a function called `rotate` that takes three arguments, `a`, `b`, and `c`. Inside the function, we create a tuple with the values of `c`, `a`, and `b`, in that order.

```

def rotate(a, b, c):

  return (c, a, b)

a, b, c = 'Doug', 22, 1984

result1 = rotate(a, b, c)

a, b, c = result1

print(a, b, c)

result2 = rotate(a, b, c)

a, b, c = result2

print(a, b, c)

result3 = rotate(a, b, c)

a, b, c = result3

print(a, b, c)

```

Next, we define three variables, `a`, `b`, and `c`, with the values 'Doug', 22, and 1984, respectively.

Then, we call the `rotate` function three times, each time passing in `a`, `b`, and `c` as arguments. We store the result of each function call in a separate variable (`result1`, `result2`, and `result3`).

Finally, we unpack the result of each function call into `a`, `b`, and `c`, and display their values using the `print` function.

When you run this code, you should see the following output:

```

1984 Doug 22

22 1984 Doug

Doug 22 1984

```

Learn more about code here:-

brainly.com/question/497311

#SPJ2


Related Questions

Drag the system component on the left to the device or program that fits with the system component.

Answers

Answer:

A. Back up software - Utility software

B. Printer - Device drivers

C. Camera - Firmware

D. Television - Firmware

E. Games console - Firmware

F. Antivirus software - Utility software

G. Disk Cleaner - Utility software

H. Video Card - Device drivers

Explanation:

Computer system components are the physical or hardware and software parts of the device. It is a combination of system software like utility software, device drivers and firmware, application software, and the hardware components and kernel.

Which of the following best describes the "friction" property of a physics material?
A. Controls how fast the object will fall due to gravity
B. Controls the maximum speed of an object
C. Controls how far an object will bounce when it collides with another object
D. Controls how much resistance is felt when two objects are in contact

Answers

Answer:

D. Controls how much resistance is felt when two objects are in contact

Explanation:

Friction is a force, the resistance of motion when one object rubs against another. Whenever two objects rub against each other, they cause friction. Friction works against the motion and acts in the opposite direction.

Most supercomputers use the _______ operating system.
a) Windows
b) iOS
c) UNIX
d) Linux

Answers

Answer: d

Explanation: Although most modern supercomputers use the Linux operating system, each manufacturer has made its own specific changes to the Linux-derivative they use, and no industry standard exists, partly because the differences in hardware architectures require changes to optimize the operating system to each hardware design.

the wi-fi radio in a smartphone has failed. which of the following is a possible solution?

Answers

Answer:

Mobile Data

Explanation:

4g data

How globalization is related to communication technology?

Answers

Answer:

hey mate there is your answer

How globalization is related to communication technology?

In the lesson, you were introduced to the difference between data, information, and knowledge. Think of an example in your life where a number could be described as data, information, and knowledge.
A file won’t open on your friend’s computer, which leads to the inevitable question: “Why do there even need to be different file types, anyway?” How would you respond?
Think about the last business that you purchased a product or a service from. What three types of software might they need? Why would they need them?
If virtual reality becomes commonly used, what are some problems and concerns that might arise?
A family member who hasn’t worked with computers before has decided to change jobs. You’ve been asked to explain some of the basics. You begin by explaining the basic idea of word processing software, spreadsheets, databases, and presentation software. You sense that the following question is coming: “Why so many different things? Why can’t there just be one software that you could use for everything?” How would you answer?

Answers

Answer:

subject  

Computers and Technology, 26.08.2021 15:30 laiba012305

A family member who hasn’t worked with computers before has decided to change jobs. You’ve been asked to explain some of the basics. You begin by explaining the basic idea of word processing software, spreadsheets, databases, and presentation software. You sense that the following question is coming: “Why so many different things? Why can’t there just be one software that you could use for everything?” How would you answer? {This is not for a quiz, test, exam so dont report me. I would ask my dad but he's at work.}

Explanation:

Answer:

information technology​ (it) pertains to the​ hardware, software, and data components. an information system​ (is) is an assembly of​ data, procedures, and people that produces information.Explanation:

What is phishing? Answer

Answers

Answer:

Phishing is a type of online scam where an attacker sends a fraudulent email purporting to be from reputable companies, designed to deceive a person into revealing sensitive and personal information (card numbers, passwords etc).

Hope this helps.

plzz help me with this question.........

Write a program to input a number find the sum of digits and the number of digits. Display the output

sample input - 7359
sample digits - 24
number of digits - 4​

Answers

Answer:

str = input("Enter a number: ")

sum = 0

for c in str:

   sum = sum + int(c)

print("Sample input - {}".format(str))

print("Sum of digits - {}".format(sum))

print("Number of digits - {}".format(len(str)))

Explanation:

That's python. Was that what you were looking for?

Answer Using Java :-

import java.util.*;

public class Digit

{

public static void main(String args[ ] )

{

Scanner in=new Scanner (System.in)

System.out.print("Enter a number: ");

int n = in.nextInt();

int sum = 0, count = 0;

while (n!=0)

{

int d = n % 10;

sum + = d;

count++;

n /= 10;

}

System.out.println("Sum of digits=" +sum);

System.out.println("Number of digits=" +count);

}

}

The colors of the pixels in a digital image are often represented by red, green, and blue values
between 0 and 255 (an RGB triplet). A photographer is manipulating a digital image to lighten it
because all of the RGB values in the image are less than 100, making it very dark. He does this
by adding 20 to the R, G, and B values of each pixel, then overwriting the original image. What
type of transformation is the photographer using on the digital image? plz help !!

Answers

Answer:

Lossless Transformation

Explanation:

dropa service or software application that relies on shared resources over the interneta software application that accesses web applications and websitespress delete to cleara company that provides access to the internetpress delete to clearan interconnected global public computer networkan information system that connects documents to each other by hypertext links

Answers

It seems like there are multiple questions in this post, so I will answer each one separately.

1. A service or software application that relies on shared resources over the internet is called cloud computing. Examples of cloud computing services include Go-ogle Dr-ive, Dro-pbox, and Micr-osoft One-Dr-ive.
2. A software application that accesses web applications and websites is called a web browser. Examples of web browsers include Go-ogle Ch-rome, Mo-zilla Fi-re-fox, and Micr-osoft Ed-ge.
3. A company that provides access to the internet is called an internet service provider (ISP). Examples of IS-Ps include Com-cast, A-T&T, and Veri-zon.
4. An interconnected global public computer network is called the internet.
5. An information system that connects documents to each other by hypertext links is called the W-orld W-ide W-eb.

Learn more about software :

https://brainly.com/question/28224061

#SPJ11

what are the characteristics of review site

Answers

Review sites are websites where people can post reviews about people, businesses, products, or services. Some of the characteristics of review sites are:

- Web 2.0 techniques: Review sites may use Web 2.0 techniques to gather reviews from site users or may employ professional writers to author reviews on the topic of concern for the site

- Self-selection bias: Most review sites make little or no attempt to restrict postings, or to verify the information in the reviews. Critics point out that positive reviews are sometimes written by the businesses or individuals being reviewed, while negative reviews may be written by competitors, disgruntled employees, or anyone with a grudge against the business being reviewed. Some merchants also offer incentives for customers to review their products favorably, which skews reviews in their favor

- Reviewer characteristics: Understanding online reviewer characteristics has become important, as such an understanding can help to identify the characteristics of trustworthy reviews. Some of the characteristics that have been studied include valence, rationality, and source

- Content characteristics: The content characteristics of online consumer reviews can make them more useful to readers. Some of the content characteristics that have been studied include the tone of the review, the level of detail, and the relevance of the review to the reader's needs

- Successful owner responses: Successful owner responses to reviews can help to improve the reputation of a business. Some of the characteristics of successful owner responses include being prompt, personalized, and professional

Class Example {
public static void main(String[] args) {
// This is the code editor
System. Out. Println(". And this is the terminal");
}
}

Answers

The provided code snippet is a basic   Java class named "Example" with a main method.

How does it work?

Inside the main method,there is a comment indicating that it is the code editor.

The code then prints out a message "And this is the terminal" using the System.out.println() statement. This statement will display the message in the terminal when the code is executed.

A code snippet is a small portion   or fragment of source code that represents a specific functionality or task. It is typically used to demonstrate or illustrate a particular programming concept, technique, or solution.

Learn more about code snippet at:

https://brainly.com/question/30467825

#SPJ1

What does DOS stand for?

Answers

Answer:

Disk Operating System

Explanation:

"DOS is a platform-independent acronym for Disk Operating System which later became a common shorthand for disk-based operating systems on IBM PC compatibles."

Which of the following terms defines a small, single-user computer used in homes and businesses?

Personal computer

Work station

Mini computer

Supercomputer

Answers

Answer:

Mini Computer

Explanation:

Person Computer. small, single-user computer; used in homes and businesses; based on a microprocessor. Microprocessor. chip which is the master control circuit of a computer. Minicomputer.

Pa brainliest po thank you

The correct option is A. Personal computer is defined as a small, single-user computer used in homes and businesses.

What is a personal computer?

A personal computer (PC) is a multifunctional microcomputer that can be used for a variety of tasks and is affordable enough for home use. Instead of being operated by a computer specialist or technician, personal computers are designed to be used directly by end users.

Personal computer (PC): compact, single-user computer with a microprocessor that is used in homes and businesses.

A personal computer (PC) is a compact computer made for solitary usage. A single-chip microprocessor serves as the central processing unit in a PC or microcomputer (CPU).

The right answer is A. Small, single-user computers used in homes and companies are referred to as personal computers.

Learn more about personal computers here:

https://brainly.com/question/14406548

#SPJ2

You would use the _______ conditional formatting options when analyzing a worksheet in which you want to highlight the highest or lowest values compared to other cells in the selection.

Answers

Answer:

Top/bottom conditional formatting

Explanation:

The top/bottom conditional formatting automatically carries out the task of finding the highest, lowest and even average values.

Conditional formatting formatting gives one the opportunity to enhance reports and dashboards as they work on excel.

You use the too/bottom formatting to highlight cells whose values of highest in a dataset and lowest in a dataset

Amit wants to capture a narrow field of view for a subject that is 90 feet away. which lens should he choose for the task?
a.
fish-eye lens
b.
telephoto lens
c.
wide-angle lens
d.
macro lens

Answers

Option B. A telephoto lens is best for capturing a narrow field of view when the subject is 90 feet away. It can zoom in and capture the subject with greater detail.

Using a Telephoto Lens to Capture a Narrow Field of View at 90 Feet

A telephoto lens is ideal for capturing a narrow field of view when the subject is far away. By using a telephoto lens, the subject can be zoomed in on and captured with greater detail. This type of lens has a longer focal length than a wide angle lens, which allows it to capture a narrower field of view while still maintaining a sharp image. It also has the ability to capture distant subjects with greater clarity and depth of field. For Amit's task of capturing a narrow field of view for a subject 90 feet away, a telephoto lens would be the best choice.

Learn more about Lens: https://brainly.com/question/25779311

#SPJ4

A _____ is a diagram that depicts a process, system or computer algorithm

a. Code
b. Program
c. Algorithm
d. Flowchart

Answers

The answer to your question is FLOWCHART (d.)

Answer:

D) Flowchart

Explanation:

Because it is the only known diagram from your 4 options.

Which of the following uses replication to Infect multiple computers?
Viruses
Trojan horse
Spyware
Worms​

Answers

Answer:

Trojan horse

Explanation:

mostly all the above mentioned use replication to infect computers but the one that uses replication to invest multiple computers at a time is Trojan horse.

hope it helps .

Answer:

trojan house

Explanation:

i just took the house

Unlike viruses, which require the spreading of a host file, __________ are standalone software and do not need help to spread.

Answers

Answer:

Worms? They reproduce themself and do not need other factors.

Explanation:

what is the set of rules that manage how data is sent and received over the internet, in the form of packets?

Answers

The set of rules that manage how data is sent and received over the internet, in the form of packets, is known as the "Internet Protocol Suite" or "TCP/IP" (Transmission Control Protocol/Internet Protocol).

which statement describes an example of database software? microsoft access enables users to create, store, and retrieve records. microsoft excel enables users to perform calculations and statistical analyses. microsoft powerpoint enables users to create animated presentations that can be projected on a screen. microsoft word enables users to write and edit text documents.

Answers

Microsoft access enables users to create, store, and retrieve records is the statement describes an example of database software.

What is database software?

A software application or utility called database software is used to build, edit, and maintain database files and records. Users of this kind of software can store data as structured fields, tables, and columns that can later be retrieved manually or programmatically.

Therefore, a good database design is one that: Organizes your data into subject-based tables to eliminate redundant information. access to the data necessary to, when appropriate, combine the data in the tables provided. supports and helps maintain the integrity and authenticity of your information A database is a planned grouping of material that has been arranged and is often kept electronically in a computer system.

To learn more about database software, visit:

https://brainly.com/question/13093522

#SPJ1

A_______VPN connection is a private network that uses a public
network to operate.

A)Point-to-Point
B)Point-to-Tunnel
C)Point-to-Site
D)Site-to-Site

Answers

Answer:

letter c. point to site po sagot diyan

which type of attack is wep extremely vulnerable to?

Answers

WEP is extremely vulnerable to a variety of attack types, including cracking, brute-force, IV (Initialization Vector) attack, and replay attack.

What is Initialization Vector?

An Initialization Vector (IV) is a random number used in cryptography that helps to ensure the uniqueness and randomness of data used in an encryption process. The IV is typically used as part of an encryption algorithm, where it is combined with a secret key to encrypt a message. The IV is unique for each encryption session, and must be unpredictable and non-repeating. A good IV should not be reused across multiple encryption sessions, and it should be kept secret from anyone who does not have access to the decryption key. Without a good IV, a cryptographic system can be vulnerable to attacks such as replay attacks, where an attacker can gain access to the system by repeating an encrypted message.

To learn more about Initialization Vector
https://brainly.com/question/27737295
#SPJ4

Do you think employers are impressed with someone who knows how to use Excel? Why or Why not?

Answers

Answer:

Explanation:

Yes, but it depends on who your applying your job for. If it's a computer based job than they will be impressed.

why do arthitects prefer memory dump to be in base 16​

Answers

Answer:

Memory dump in  base 16​ is human friendly

Explanation:

Hexadecimal numbers are human friendly and hence it is very easy to express the binary number in a more human-friendly as compared to any other base number systems. It is also used to trace errors in the storage

hence, the Architects prefer memory dump to be in base 16​

Select all that apply. How do you save presentations?

Select the Save option in the Tools menu.
Click in the Task Pane.
Name them so you can find them later.
Click on an icon.
Select the Save option in the File menu.

Answers

Answer:

it's number 3 if I remember for Microsoft Excel

Explanation:

click “File” from the menu in the top left-hand corner of Excel. Then click “Save As

20 points! Help ASAP! During which phase of a well-structured study session is each occurring?



1. The students ask the teacher for clarification on material that the group has conflicting opinions about.


~not prepare~


2. One student tells another student, who missed the last study session, what was discussed.


~not discuss~


3. Group members write down questions that they think will appear on the test, and then exchange papers.


~not review~



Options:

•review

•discuss

•drill

•prepare

Answers

Answer:

I ended up getting most of them wrong, but heres the answers.

Explanation:

20 points! Help ASAP! During which phase of a well-structured study session is each occurring?1. The

Answer:

It's drill, discuss, review, and prepare

Explanation:

which item is developed last in the cyclical design process

Answers

The item that is developed last in the cyclical design process is known to be Prototype.

What is the last step in the design process?

Designers which can be known to be evaluators are said to test the complete product using the best solutions known to be in the Prototype stage.

Note that The item that is developed last in the cyclical design process is known to be Prototype.

Learn more about  design process from

https://brainly.com/question/10039920

#SPJ1

List five types of system information that can be obtained from the Windows Task Manager. How can you use this information to confirm the presence of malware on a system

Answers

Answer:

Part A;

Five types of system information that can be obtained from the Windows Task Manager includes;

1) The processes taking place

2) The performance of the system components, including the, CPU, Memory, Disk, Wi-Fi, GPU, and a live summary of the metrics of the computer

3) The App  history

4) The list of startup

5) The current users of the computer

Part B;

By going through list of active processes on the Windows Task Manager, a malware can be detected as a rogue or unidentified process that may be running on the background. The name of a process may seem legit, but however, the process is not supposed to be running, such as a program which is not running or installed on the system  but the process is seen running on the Windows Task Manager, that is a sign of a malware on the system

Explanation:

How can your web page design communicate your personal style

Answers

Answer:

Web design is very unique, you can express your feelings through creating a page.

Other Questions
What is the slope of this line? Which of the following statements is consistent with the Lucascritique?A. Econometric analysis always provides a reliable foundation for policy making.B. Policy recommendations are more likely to be correct if based on empirical studies rather than simple intuition.C. Data from the past can serve as a solid foundation for predicting what will happen in the future.D. Policy recommendations based on econometric models using data from the past may be flawed. Compare these costs.48 paper plates for $2.9975 paper plates for $3.99 Description for Iiotibial band (ITB) syndrome what is the the importance of the rule of law "Hunter read 40 pages in his history book inone hour.Rate of change is what causes huntingtons disease? a. an iron deficiency during childhood b. a single recessive gene on chromosome 4 c. a single dominant gene on chromosome 4 d. exposure to environmental neurotoxins In the years leading up to world war 11, how were germnay and japans goal similar find the direction in which the maximum rate of change occurs for the function f ( x , y ) = 3 x sin ( x y ) at the point (4,1). give your answer as a unit vector. round to 4 decimal places. An 8-foot roll of wrapping paper costs $12.48. What is the price per inch? Let x and y be vectors for comparison: x = (4, 20) and y = (18, 5). Compute the cosine similarity between the two vectors. Round the result to two decimal places. A suspicious monkey offers you and yourclassmates fruit to eat. As you consider eatingthe fruit, he tells you that 60 out of 1240 fruittrees are poisonous. What percent of trees onthe island are poisonous ?(Round to nearest tenth) What is the term used to describe the risk that auditors may fail to appropriately modify their opinion on the financial statements at the overall engagement level, and the risk that a particular assertion about an account balance is materially misstated at the financial statement assertion level? I need to know the area of this triangle and I would like to have an explanation because I dont know how to do it I know the formula just not how to get the height Simplify the equation (2+3 + 1/2+3) .For search and seizure to be lawful, a valid warrant based on probable cause is required. The 4 exceptionsto this are _______,________,______, and,________ The image depicts a Chinese Confucian scholar and two female attendants. The image can best be used as a source of information about the can someone help please (highlighted in blue) The coordinates for one vertex of a rectangle are (1. 25,1). The length of the rectangle is 2. 5 units, and the width of the rectangle is 1. 25 units. Draw this rectangle on the coordinate grid If 3 inches equals 4 feet how much does 4 inches equal