Review of date format
Write a program to format to format yyyy/mm/dDReceive from the user and check whether the date received in the correct format is correct.
Example:
Write a program to format to format yyyy/mm/dDReceive from the user and check whether the date received in the correct format is correct.
Example:
y = int(input('enter the year : ')) m = int(input('enter the month : ')) d = int(input('enter the day : ')) if m > 12 and d > 30 : print('false') else : print('true')
import re from datetime import datetime def is_valid_date(date_string): # Review of date format using Regex pattern = r'^\d{4}/\d{2}/\d{2}$' if not re.match(pattern, date_string): return False # Convert the history of history to the Datetime object and examine the accuracy of history try: year, month, day = map(int, date_string.split('/')) datetime(year, month, day) return True except ValueError: return False def main(): date_input = input("تاریخ را به فرمت yyyy/mm/dd وارد کنید: ") is_valid = is_valid_date(date_input) print(is_valid) if __name__ == "__main__": main()
user_date = input("Please enter date: (format: yyyy/mm/dd)") lst_date = user_date.split("/") if 0 < int(lst_date[1]) <= 12 and 0 < int(lst_date[2]) <= 31: print(True) else: print(False)
from datetime import datetime user_date = input("Please enter date: (format: yyyy/mm/dd)") try: datetime.strptime(user_date, "%Y/%m/%d") print (True) except : print (False)
year = int(input("year: ")) month = int(input("month: ")) day = int(input("day: ")) format_ymd = f"{year}/{month}/{day}" if year > 2025: print(f"History : {format_ymd} year error") print("False") elif month > 12: print(f"History : {format_ymd} month error") print("False") elif month > 30: print(f"History : {format_ymd} day error") print("False") elif year < 2025 and month < 13 and day < 31: print(f"History : {format_ymd}") print("True") else: print("Not")
tarikh = int(input("tarikh miladi":) sal = tarikh[0:4] mah=tarikh[4:6] rooz=tarikh[6:8] mah ={"1":"jan" ,"2": "feb", "3": "mar" ,"4":"apr" , "5": "may" ,"6": "jun" , "7":"jul" , "8": "Aug" , "9": "sep" , "10": "oct", "11": "nov" , "12": "dec" } if tarikh in mah : print(" true ") else: print("false")
Submitting answers is currently unavailable.
Write a program that receives a rectangular length and width from the input and prints its area in the output
Write a program that receives the number of random numbers and its interval from the user and produces the number of random numbers. Example: Enter A Number: 10 Enter Min: 1 Enter Max: 10 9 4 6 5 2 8 1 7 9 2 2
Write a program that receives a number from the input and increases the number 2 and prints in the output. This trend continues until the number 0 is not arrived
We want to open the cow door, we don't know the password, but we have the following information: the second -digit safing password and the fifth digit equivalent to the first number of the first digit of a larger unit ...
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.