You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1022 B
Python

# Activity Solution:
# 1. In the s02 folder, create an "activity" folder, and inside it, create an "activity.py" file.
# 2. Accept a "year" input from the user and determine whether it is a leap year or not.
year = int(input("Please input a year:\n"))
if year % 4 == 0 and year % 100 != 0 or year % 400 == 0:
print(f"{year} is a leap year.")
else:
print(f"{year} is not a leap year."
# 3. Accept two numbers ("row" and "column") from the user and create a grid of asterisks based on those values.
row = int(input("Enter number of rows:\n"))
col = int(input("Enter number of columns:\n"))
i = 1
j = 1
str = ""
while i <= row:
while j <= col:
str += "*"
j += 1
print(str)
i += 1
# 4. Update your local session Git repository and push to Git with the commit message "Add activity code s02".
# 5. Add the repository link in Boodle for s02.
# Stretch Goal:
# 1. Add a validation for the leap year input:
# - Strings are not allowed for inputs
# - No zero or negative values