Question

Which of these characterizes a procedural program? (1 point)
def inputName(): name = input("What is your name?") return name
class Name: def __init__(self, name): self.name = name
print("What is your name?")
name = input("What is your name?")

Answers

GPT-4o mini
A procedural program is typically characterized by the use of functions to perform tasks, following a sequence of steps and focusing on the procedure itself rather than on the data. In your examples:

1. The first snippet (`def inputName(): ...`) is a function definition which characterizes procedural programming, as it defines a series of steps to gather input.
2. The second snippet creates a class (`class Name:`), which aligns more with object-oriented programming rather than procedural programming.
3. The third snippet uses a direct input approach but does not encapsulate it in a function, which is a more procedural style than the class definition.

Out of the options provided, the most clearly procedural element is:

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

This snippet defines a specific procedure (function) to input a name, which is a hallmark of procedural programming.

Related Questions