#!/usr/bin/env python # file: data/courses/ece_1111/current/quizzes/qu_02/pynkivskyi_oleg/p02 # 20230827 (JP): first version # # This is a Python program tha # (1) prints the program name to the terminal (stdout). #(2) accepts an integer argument from the command line. #(3) computes the factorial of the argument. #(4) prints the value to the terminal (stdout). # import system modules # import os import sys #------------------------------------------------------------------------------ # # global variables are listed here # #------------------------------------------------------------------------------ #------------------------------------------------------------------------------ # # functions are listed here # #------------------------------------------------------------------------------ # function: main # def main(argv): # print program name for (1) arguments print("program name: %s" % (argv[0])) # Input: An integer number num = (sys.argv[1]) # Initialize the factorial variable to 1 factorial = 1 # Calculate the factorial using a for loop for i in range(1, num + 1): factorial *= i # Output: The factorial of the number print(f"The factorial of {num} is {factorial return True # begin gracefully # if __name__ == '__main__': main(sys.argv[0:])