filmov
tv
Absolute Beginers_Codekata Problem solving using Python (11-15)

Показать описание
Hey guys, Welcome to FORMAL INFINITY Channel, In this video we would discuss the solution for Codekata programing problems using python in Guvi. In this specific video we have discussed Input and Output related problems in Guvi. We would continue this series of video for covering all the topics under codekata.
If you find our videos useful, please like or comment and don't forget to subscribe our channel to follow frequent videos and regular updates posted in our channel.
And If you haven't checked Playlists available in our channel, The link for all the available playlists is given below:
___________________________________________________________
Question_1:-
You are given the coefficients of a quadratic equation in order A, B & C.
Where A is the coefficient of X2, B is the coefficient of X and C is the constant term in the most simplified form.
Example: For X2 + 5X + 6 = 0, you are given the input as: 1 5 6.
Write a program to find all of the roots of the quadratic.
Note: The output should be up to 2nd decimal place (round off if needed) and in case of a recurring decimal use braces.
Note: Use Shri Dharacharya's Method to solve i.e. X = {-b + √(b² - 4ac) } / 2a & {-b-√(b² -4ac)} / 2a
Input Description:
Three numbers corresponding to the coefficients of x(squared), x and constant are given as an input in that particular order
Output Description:
Print the two values of X after rounding off to 2 decimal places if required.
Sample Input :
1 5 6
Sample Output :
-2.00
-3.00
**************************
a,b,c = map(int,input().split())
d = ((b**2)-(4*a*c))**0.5
m = (d-b)/(2*a)
n = -(d+b)/(2*a)
print(f'{m:.2f}')
print(f'{n:.2f}')
************************
___________________________________________________________
Question_2:-
Print "Odd" or "Even" for the corresponding cases.
Note: In case of a decimal, Round off to nearest integer and then find the output. Incase the input is zero, print "Zero".
Input Description:
A number is provided as the input.
Output Description:
Find out whether the number is odd or even. Print "Odd" or "Even" for the corresponding cases. Note: In case of a decimal, Round off to nearest integer and then find the output. In case the input is zero, print "Zero".
Sample Input :
2
Sample Output :
Even
*********************
a = int(input())
if a % 2 == 0:
print("Even")
else:
print("Odd")
*********************
___________________________________________________________
Question_3:-
Let "A" be a year, write a program to check whether this year is a leap year or not.
Print "Y" if its a leap year and "N" if its a common year.
Input Description:
A Year is the input in the form of a positive integer.
Output Description:
Print "Y" if its a leap year and "N" if its a common year.
Sample Input :
2020
Sample Output :
Y
**********************
A = int(input())
if A%4 == 0:
if A % 1000 == 0:
if A % 400 == 0:
print('Y')
else:
print("N")
else:
print("Y")
else:
print("N")
*********************
___________________________________________________________
Question_4:-
You will be provided with a number. Print the number of days in the month corresponding to that number.
Note: In case the input is February, print 28 days. If the Input is not in valid range print "Error".
Input Description:
The input is in the form of a number.
Output Description:
Find the days in the month corresponding to the input number. Print Error if the input is not in a valid range.
Sample Input :
8
Sample Output :
31
***********************
a = int(input())
b = [1,3,5,7,8,10,12]
c = [4,6,9,11]
d = 2
if a in b:
print(31)
elif a in c:
print(30)
elif a == 2:
print(28)
else:
print('Error')
*********************
___________________________________________________________
Question_5:-
Let "A" be a string. Remove all the whitespaces and find it's length.
Input Description:
A string is provide as an input
Output Description:
Remove all the whitespaces and then print the length of the remaining string.
Sample Input :
Lorem Ipsum
Sample Output :
10
**********************
a = input()
new = ''.join(list1)
print(len(new))
**********************
If you find our videos useful, please like or comment and don't forget to subscribe our channel to follow frequent videos and regular updates posted in our channel.
And If you haven't checked Playlists available in our channel, The link for all the available playlists is given below:
___________________________________________________________
Question_1:-
You are given the coefficients of a quadratic equation in order A, B & C.
Where A is the coefficient of X2, B is the coefficient of X and C is the constant term in the most simplified form.
Example: For X2 + 5X + 6 = 0, you are given the input as: 1 5 6.
Write a program to find all of the roots of the quadratic.
Note: The output should be up to 2nd decimal place (round off if needed) and in case of a recurring decimal use braces.
Note: Use Shri Dharacharya's Method to solve i.e. X = {-b + √(b² - 4ac) } / 2a & {-b-√(b² -4ac)} / 2a
Input Description:
Three numbers corresponding to the coefficients of x(squared), x and constant are given as an input in that particular order
Output Description:
Print the two values of X after rounding off to 2 decimal places if required.
Sample Input :
1 5 6
Sample Output :
-2.00
-3.00
**************************
a,b,c = map(int,input().split())
d = ((b**2)-(4*a*c))**0.5
m = (d-b)/(2*a)
n = -(d+b)/(2*a)
print(f'{m:.2f}')
print(f'{n:.2f}')
************************
___________________________________________________________
Question_2:-
Print "Odd" or "Even" for the corresponding cases.
Note: In case of a decimal, Round off to nearest integer and then find the output. Incase the input is zero, print "Zero".
Input Description:
A number is provided as the input.
Output Description:
Find out whether the number is odd or even. Print "Odd" or "Even" for the corresponding cases. Note: In case of a decimal, Round off to nearest integer and then find the output. In case the input is zero, print "Zero".
Sample Input :
2
Sample Output :
Even
*********************
a = int(input())
if a % 2 == 0:
print("Even")
else:
print("Odd")
*********************
___________________________________________________________
Question_3:-
Let "A" be a year, write a program to check whether this year is a leap year or not.
Print "Y" if its a leap year and "N" if its a common year.
Input Description:
A Year is the input in the form of a positive integer.
Output Description:
Print "Y" if its a leap year and "N" if its a common year.
Sample Input :
2020
Sample Output :
Y
**********************
A = int(input())
if A%4 == 0:
if A % 1000 == 0:
if A % 400 == 0:
print('Y')
else:
print("N")
else:
print("Y")
else:
print("N")
*********************
___________________________________________________________
Question_4:-
You will be provided with a number. Print the number of days in the month corresponding to that number.
Note: In case the input is February, print 28 days. If the Input is not in valid range print "Error".
Input Description:
The input is in the form of a number.
Output Description:
Find the days in the month corresponding to the input number. Print Error if the input is not in a valid range.
Sample Input :
8
Sample Output :
31
***********************
a = int(input())
b = [1,3,5,7,8,10,12]
c = [4,6,9,11]
d = 2
if a in b:
print(31)
elif a in c:
print(30)
elif a == 2:
print(28)
else:
print('Error')
*********************
___________________________________________________________
Question_5:-
Let "A" be a string. Remove all the whitespaces and find it's length.
Input Description:
A string is provide as an input
Output Description:
Remove all the whitespaces and then print the length of the remaining string.
Sample Input :
Lorem Ipsum
Sample Output :
10
**********************
a = input()
new = ''.join(list1)
print(len(new))
**********************
Комментарии