PROGRAMING 511 Assignment
PROGRAMING 511 Assignment
PROGRAMMING 511
ST
1 SEMESTER ASSIGNMENT
Date Submitted:
Moderator's Comments:
1.1 Explain the role and importance of comments in Python programming. How do comments enhance
code readability and maintainability? (5 Marks)
1.2 Discuss the concept of variables in Python, contrasting them with constants. Provide examples to
illustrate how variables are used differently from constants in a program. (5 Marks)
1.3 Detail the significance of different data types in Python. Provide examples of at least three data
types and scenarios where each is appropriately used. (5 Marks)
1.4 Outline the process of input, processing, and output in Python programs. Describe a real-world
scenario where this process is crucial, such as data entry and processing in a retail system. (5 Marks)
2.1 Explain how Python handles arithmetic operations with an emphasis on operator precedence. Use
examples to illustrate how Python evaluates complex arithmetic expressions. (5 Marks)
2.2 Describe the use and functionality of escape characters in Python strings. Provide examples of
how escape characters can be used in formatting text output, such as in generating a formatted
report. (5 Marks)
2.3 Discuss the concept of string concatenation and formatting in Python with examples. Explain how
these concepts can be applied in generating user-friendly messages or data output. (5 Marks)
2.4 Define named constants in Python and explain their purpose. Illustrate with an example how using
named constants can make a program more readable and maintainable, such as in a scientific
calculation. (5 Marks)
3.1 Develop a Python script to simulate a basic user authentication system using if-else statements
and logical operators. The script should prompt the user for a username and password and validate
them against predefined credentials. (20 Marks)
3.2 Write a Python program using a while loop to calculate and display the factorial of a user-input
number. Ensure your program handles invalid inputs gracefully. (15 Marks)
3.3 Design a Python script that uses a for loop to print a pattern of numbers or characters. For instance, create a
script that prints a pyramid pattern using asterisks (*) based on a user-input height. (15 Marks)