Here I am providing answer for the above questions:
1).
monthrange is function which will take 2 inputs ( year and month ), and returns two inputs (first week day of month taking monday as '0' and no.of days in the month).
Example Code:
>from calendar import monthrange
>monthrange(2019, 10) #asking for october month in 2019.
Result:
>(1, 31) #here 1st of oct is tuesday so it is giving '1'(taking monday as '0') and no.of days in october are '31'.
2).
f = open("test.txt",'r') #opening the file
string=f.readline() # reading the string from file
vowels=0 #initializing variables to '0'
consonents=0
whitespaces=0
for element in string: #iterating over string t
if (element == 'a' ||element == 'e' ||element == 'i' ||element ==
'o' ||element == 'u' ||element == 'A' ||element == 'E' ||element ==
'I' ||element == 'O' ||element == 'U' ):
vowels++
elif(element == ' '):
whitespaces++
else:
consonents++
print(vowels)
print(consonents)
print(whitespaces)
Hoping that the above answer will help you...Thank you...
Get Answers For Free
Most questions answered within 1 hours.