Skip to content

sakshi892001/Module3_Python_Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Module 3: Control Structures in Python

Overview

This repository contains two Python scripts for the Module 3 assignment of the Tutedude Python course, focusing on control structures:

  1. even_odd.py: Checks whether a user-provided integer is even or odd using an if-else statement.

  2. sum_integers.py: Calculates the sum of integers from 1 to 50 using a for loop.

Prerequisites

  • Python 3.x installed (verify with python --version).
  • Git installed (verify with git --version).
  • Visual Studio Code (VS Code) with Git extension enabled.

Repository Setup

  1. Clone the Repository:
  • Clone this repository to your local machine:

    git clone https://github.com/sakshi892001/Module3_Python_Assignment.git
    
  1. Navigate to the Repository Folder:

    cd Module3_Python_Assignment
    
  2. Run the scripts:

    python even_odd.py
    python sum_integers.py
    

Task 1 : Check if a number is even or odd

  • File : even_odd.py
  • Functionality : Takes an integer input from the user, checks if it's an even or odd using if-else statement, and displays the result. Handles invalid inputs (e.g, non-integer values).

Task 2: Sum of Integers from 1 to 50 Using a Loop

  • File : sum_integers.py
  • Functionality : Uses a for loop to iterate over numbers from 1 to 50, calculates their sum, and displays the result.

Error Handling

  • Task 1: Catches ValueError for non-integer inputs (e.g., letters, decimals). Provides a clear error message.

  • Task 2 : No user input, so no error handling is required, but the loop is robust for the fixed range.

Notes

  • Ensure Python is installed and added to your system's PATH.

  • Test the scripts with various inputs to verify robustness.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages