Question

Which of these characterizes a procedural program?

(1 point)
Responses

def inputName():

name = input("What is your name?")

return name

def inputName(): name = input("What is your name?") return name

class Name:

def __init__(self, name):

self.name = name

class Name: def __init__(self, name): self.name = name

print("What is your name?")

print("What is your name?")

name = input("What is your name?")

Answers

GPT-4o mini
A procedural program is characterized by a linear sequence of procedures or functions that operate on data. In the options provided, the first two code snippets define a function (`inputName`) that prompts the user for input, which aligns with procedural programming.

However, the last two snippets that define a class (`Name`) are indicative of object-oriented programming (OOP), which focuses on objects and their interactions rather than just on procedures or functions.

Therefore, the piece of code that best characterizes a procedural program is:

```python
def inputName():
name = input("What is your name?")
return name
```

This snippet defines a simple function that captures procedural style.