Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

challenge activity 4.2.2. basic if - else. 696582.5708494.qx3zqy7 jump …

Question

challenge activity 4.2.2. basic if - else. 696582.5708494.qx3zqy7 jump to level 1 write an if - else statement for the following: if barcode_check_digit is equal to 7, execute group_id = 1. else, execute group_id = barcode_check_digit. ex: if barcode_check_digit is 3, then group_id = 3. 1 barcode_check_digit = int(input()) # program will be tested with values: 5, 6, 7, 8. 2 3 \\\ your code goes here \\\ i 4 5 print(group_id) 6

Explanation:

Step1: Get input and convert to int

barcode_check_digit = int(input())

Step2: Initialize group_id variable

group_id = 0

Step3: Add if-else condition logic

if barcode_check_digit == 7:
    group_id = 1
else:
    group_id = barcode_check_digit

Step4: Print the final group_id

print(group_id)

Answer:

barcode_check_digit = int(input())
group_id = 0
if barcode_check_digit == 7:
    group_id = 1
else:
    group_id = barcode_check_digit
print(group_id)