Skip to content

fenyx-it-academy/vit-en-python-6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

vit-en-python-6

Exception Handling Assignment 1: Robust Calculator App

Objective: Build a simple calculator app that handles various exceptions gracefully.

Tasks:

  • Write functions for basic arithmetic operations (add, subtract, multiply, divide)
  • Implement input validation and error handling to manage non-numeric inputs and division by zero errors.
  • Provide user-friendly error messages and allow the user to correct their inputs.

Exception Handling Assignment 2: Robust User Input Parser

Objective: Create a script that asks the user to input numbers and performs calculations, while handling various input-related exceptions.

Tasks:

  • Prompt the user to input a series of numbers, separated by commas.
  • Write a function to parse these numbers and calculate their sum and average.
  • Implement exception handling for scenarios such as invalid input (non-numeric values), empty input, or improper formatting (like missing commas).
  • In case of an exception, display a user-friendly error message and give the user a chance to re-enter the data correctly.

Modules and Packages Assignment 1: Create and Use Your Own Module

Objective: Develop a custom Python module and then use it in a separate Python script.

Tasks:

  1. Creating the Module:
  • Develop a module named utilities.py.
  • Inside this module, write at least three useful functions. For example, a function to calculate the factorial of a number, another to check if a number is prime, and a third one to generate a list of Fibonacci numbers up to a given number.
  • Add proper documentation (docstrings) to each function explaining its purpose, inputs, and outputs.
  1. Using the Module:
  • Create a separate Python script named main.py.
  • In this script, import your utilities module.
  • Use the functions from the utilities module to perform different tasks. For example, ask the user to input a number and then calculate and display the factorial of that number, check if it’s prime, and display the Fibonacci sequence up to that number.
  • Ensure that the user inputs are validated and handled appropriately.

Modules and Packages Assignment 2: Creating a Dice Simulator using Python’s Random Module

Objective:

To build a simple dice simulator that generates random dice rolls, utilizing your knowledge of Python modules and packages.

Task Description:

  1. Module Exploration:
    • Begin by researching the random module in Python. Understand its purpose and explore the different functions it offers.
  2. Dice Simulator Program:
    • Write a Python program called dice_simulator.py.
    • Your program should simulate the rolling of a standard six-sided dice.
    • Use the randint() function from the random module to generate a random number between 1 and 6, inclusive. This represents the dice roll. p3. User Interaction:
    • Allow the user to roll the dice by inputting a command, like pressing ‘r’ or ‘roll’.
    • After each roll, display the outcome to the user.
    • Ask the user if they would like to roll again. The program should continue until the user decides to stop.
  3. Enhancements (Optional):
    • Enhance your simulator by adding the functionality to simulate different types of dice (e.g., 4-sided, 8-sided, etc.).
    • Implement error handling for invalid user inputs.
    • Add comments to your code explaining your logic.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published