Skip to content

Latest commit

 

History

History
45 lines (36 loc) · 2 KB

File metadata and controls

45 lines (36 loc) · 2 KB

Homework 2: Python Basics

Instructions

Complete the following exercises using the code and concepts from workshop_2. All work should be committed to your GitHub repository that you created in Homework 1.

1. Variables and Naming

  • Create a Python script that defines at least three variables using proper naming conventions (as shown in naming_convention.py).
  • Print their values using string formatting.
  • Use meaningful variable names that describe their purpose.

2. Type Casting

  • Create a script that demonstrates the conversion between different data types (int, float, str).
  • Show examples of type casting similar to those in type_casting.py.
  • Include examples with rounding numbers.

3. String Manipulation

  • Create a script that demonstrates different string creation methods (single quotes, double quotes, multi-line).
  • Use escape characters and string operations.
  • Print the length of different strings as demonstrated in strings.py.

4. Average Calculation

  • Write a script that calculates and displays the average of three numbers.
  • Use the approach shown in workshop_2/average.py.
  • Format the output to display the average with 2 decimal places.

5. Input Basics

  • Create a script that asks the user for their name and age using the input() function.
  • Convert the age input to an integer as shown in input_basics.py.
  • Print personalized output using the collected information.

Submission Guidelines

  1. Create a folder named homework_2 in your GitHub repository.
  2. Create separate .py files for each exercise (5 files total).
  3. Include meaningful comments in your code explaining your logic.
  4. Make sure to commit and push your changes to GitHub.
  5. Test all your scripts to ensure they work as expected.

Evaluation Criteria

  • Proper use of Python syntax and naming conventions
  • Correct implementation of type casting
  • Effective string manipulation techniques
  • Proper handling of user input
  • Code organization and readability
  • Following the submission guidelines