Answer:
def count_digits(val):
count_lst = [0] * 10
val = str(val)
for digit in val:
if digit == "0":
count_lst[0] += 1
elif digit == "1":
count_lst[1] += 1
elif digit == "2":
count_lst[2] += 1
elif digit == "3":
count_lst[3] += 1
elif digit == "4":
count_lst[4] += 1
elif digit == "5":
count_lst[5] += 1
elif digit == "6":
count_lst[6] += 1
elif digit == "7":
count_lst[7] += 1
elif digit == "8":
count_lst[8] += 1
elif digit == "9":
count_lst[9] += 1
return count_lst
Explanation:
Create a function called count_digits that takes one integer parameter, val
Initialize a count_list that will hold the counts for the digits in the val
Convert val to string
Initialize a for loop that iterates through the val
Inside the loop, check each digit in val and increment its corresponding position in the count_list
When the loop is done, return the count_list
Three inputs have 8 possible states.
Here they are:
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Answer: I think the answer is A
Explanation:
If i'm wrong i'm sorry
One of the best ways to code effective programs is to write so-called <u>structured</u> programs, using the sequential, selection, or repetition logic structures.
Structured programs are program types that aim to improve the clarity of program codes to make them readable and reusable.
Structural codes such as the if/then/else for selection and while/for repetition are used to achieve these goals.
So, structured programs are used to write programs that follow the sequential, selection, and repetition logic structures.
Learn more about structured programs here:
brainly.com/question/25770844