Quick actions

cmd+k|ctrl+k

Navigation

Languages

ex35_pyfml.py

Snippet info

Language

Python

Visibility

public

Author

cuongquach.learning

Created

2016-09-19T16:22:24Z

Updated

2016-09-19T16:31:02Z

# Exercise 3.5
# Pyfml course
# Name : Quach Chi Cuong
# Glot.io : https://glot.io/snippets/eilh1zik1r
# Requirement : nhap 1 so trong day tu 1 -> 12, xuat ra output ve ten thang (tieng anh) va so ngay trong thang.


## Nhap so trong day tu 1 -> 12
input = 7


## Khoi tao list thang, list thang 31 ngay, list thang 30 ngay va thang 28 ngay.
lst_month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]
month31 = ['January', 'March', 'May', 'July', 'August', 'October', 'December']
month30 = ['April', 'June', 'September', 'November']
month28 = ['February']


## Kiem tra dieu kien input nam trong day 1 -> 12
if input < 1 or input > 12:
	print('- So input khong hop le.')
else:
	## Lay ten thang tuong ung index list thang.
	month_name = lst_month[input - 1]
	if month_name in month31:
		days_of_month = 31
	elif month_name in month30:
		days_of_month = 30
	elif month_name in month28:
		days_of_month = 28
	print('Input = ',input,'\nOutput = ',month_name,days_of_month)
INFO