CodeSolved

A comprehensive source of programming questions and exercises

History Separation

Practice Easy 1383/ Download 664 Views

Write a program that receives a historical in yyyy/mm/dd format and prints year, month and day

14 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
while True :
    day = input("Enter day(1-31) : ")
    month = input("Enter month(1-12) : ")
    year = input("Enter year(yyyy) : ")
    if len(day) > 2 or not 1 <= int(day) <= 31 :
        print("Please enter a valid(1-31) : ")
        continue

    if len(month) > 2 or not 1 <= int(month) <= 12 :
        print("Please enter a valid(1-12) : ")
        continue
        
    if len(year) != 4 or not year.isdigit() :
        print("Please enter a valid(yyyy) : ")
        continue
        
    break

print(f"{year}/{month.zfill(2)}/{day.zfill(2)}")
Emrimo Download Python
i=input('tarikh ra vared konid mesal(1373/01/15):')

y,m,d=i.split('/')
print(y,'year')
print(m,'month')
print(d,'day')
Maryam.n Download Python
# this is python code to split date:
date=input("enter the date in this format: yyyy/mm/dd")
y=[]
m=[] 
d=[]
for  i in  range(10): 
  if i<=3:
    y.append(date[i])
  elif i>4 and i<7:
    m.append(date[i])
  elif i>=8 :
    d.append(date[i])
print( "your date is: year: ",''.join(y),"mount is :",''.join(m), "and day is:", ''.join(d) )
Forough Download Python
dateInput = input("Enter date with this format(yyyy/mm/dd):")
print(f"day = {dateInput[-2:]}")
print(f"month = {dateInput[5:7]}")
print(f"year = {dateInput[0:4]}")
User 889 Download Python
tarikh = int (input("what yor tarikh : ")
sal=trikh[0:4]
mah= tarikh[4:6]
roz=tarikh[6:]
mah1={"01" : "farvardin " , "02" : "ordibehesht", "03" : "khordad" ,"04" : "tir" , "05" :"mordad" , "06": "sharivar" ,"07" : "mehr" , "08" : "aban" , "09" :"azar" , "10" : "day" , "11" : "bahman" , "12" : "esfand"}
print (f"sal \n, mah={mah1} \n, roz \n")
date = input("Enter a date in yyyy/mm/dd format: ")
year, month, day = date.split('/')
print(f"Year: {year}")
print(f"Month: {month}")
print(f"Day: {day}")

No need to create additional variables and occupy memory that has been modified above Alvandsina


x = input('please enter date like 2024/11/28 ...')
x = x.split('/')
print(f'Year is {x[0]}')
print(f'Month is {x[1]}')
print(f'Day is {x[2]}')
Alvandsina Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close