Python Homework Assignment

Practice All Core Concepts

This homework covers all the key Python concepts you learned so far. Attempt each problem using the appropriate Python constructs.

Remember to write clean, readable code and comment your work if needed!

Assignment 01: Variables and Data Types

Instructions:

  • Create 5 variables of different data types (int, float, string, bool, list).
  • Print each variable along with its type.

Assignment 02: Operators and If-Else

Instructions:

  • Ask the user for two numbers.
  • Perform arithmetic operations (+, -, *, /) and display results.
  • Use an if-else statement to print which number is greater.

Assignment 03: Practice Class

Instructions:

  • Create a program that asks the user to input their name and age.
  • Print a welcome message with the details.

Assignment 04: Switch-Case (If-Elif)

Instructions:

  • Ask the user for a day number (1-7).
  • Print the corresponding day of the week using if-elif-else statements.

Assignment 05: Lists, Tuples, Sets, and Dictionaries

Instructions:

  • Create a list, tuple, set, and dictionary with 5 elements each.
  • Perform one operation on each data structure (e.g., add, remove, access element).

Assignment 06: For Loop

Instructions:

  • Print all even numbers from 1 to 50 using a for loop.
  • Print the multiplication table of 9 using a for loop.

Assignment 07: While Loop

Instructions:

  • Ask the user for a number and print all numbers from that number down to 1 using a while loop.
  • Sum all numbers from 1 to n using a while loop and display the result.

Assignment 08: Functions

Instructions:

  • Write a function called is_even(n) that returns True if n is even, else False.
  • Write a function called calculate_square(n) that returns the square of a number.
  • Test both functions with different inputs.

If you need help

Good luck! 💻🚀