Answer:
i think its d sorry if i am wrong
Answer:
The answer is "Option b"
Explanation:
In the given code three-class C1, C2, and C3 are declared, in which C2 and C3 extend the class C1. In the next line, C2 and C3 object are created, that is c2 and c3. and in the last line c2 class object holds two-class C2, C1, and one object c3 value, this code will give runtime error because it can't cast object from sibling class, and wrong choices can be defined as follows:
- In option a, It is not correct because it can't cast c3 object into c2 object.
- In option c, It is not correct because it performs multiple casting in nested forms.
- In option d, It is wrong because the statement is not correct.
Answer:
Program:
month=['January', 'Februrary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] #list which stores the name of the month.
CheckMonth= int(input("Enter the number of the month")) #it is used to take the inputs from the user.
if CheckMonth>=1 and CheckMonth<=12: #check the condition for valid month.
print(str(CheckMonth)+" is a valid month which name is: "+ str (month [CheckMonth-1])) #print the name of month which is enter by the user.
else:
print(str(CheckMonth)+" is not a valid month, please enter the valid month") # print for the invalid month.
Output:
- If the user inputs 1, it will prints "1 is a valid month which name is: January".
- If the user inputs is 0, then it will prints "0 is not a valid month, please enter the valid month"
Explanation:
- The above program is in python language, in which the first line of the code is used to hold the list of the month.
- Then the second line is used to render a message for the user input, take the input from the user and save it into a variable.
- Then that value is checked by the if-condition that it lies in between 1 to 12 or not.
- If it lies, then print the valid month otherwise it prints that the month is invalid.