Given a string in camel case, write a python program to convert the given string from camel case to snake case.
how to slove and what is wrong in my code
w = input()
first_char = w[0]
first_char = first_char.lower()
#print(first_char)
remining_chars = w[1:]
capl = 0
for char in remining_chars:
if char == char.upper():
break
capl -= 1
lower = w[:capl].lower()
new = w[lower:]
print(new)
Last half of List:
You are given an integer N as input. Write a program to read N inputs and print a list containing the elements in the last half of the list.
The first line of input is an integer N. The second line contains N space-separated integers.
Explanation
In the example, we are given
6 numbers 1, 2, 3, 4, 5, 6 as input.
The last half of elements of the list are 4, 5, 6. So, the output should be [4, 5, 6].
In the example, we are given
5 numbers 1, 11, 13, 21, 19 as input. The last half of elements of the list are 21, 19. So, the output should be [21, 19].
Sample Input 1
6
1 2 3 4 5 6
Sample Output 1
[4, 5, 6]
Sample Input 2
5
1 11 13 21 19
Sample Output 2
[21, 19]
First and Last Elements of List
You are given an integer N as input. Write a program to read N integers and print a list containing the first and last two inputs.
The first line of input is an integer N. The next N lines each contains an integer.
Explanation:
In the given example, we are given
6 numbers 1, 2, 3, 4, 5, 6 as input.
The list should contain first two integers 1, 2 and last two integers 5, 6 So, the output should be [1, 2, 5, 6].
Sample Input 1:
6
1
2
3
4
5
6
Sample Output 1:
[1, 2, 5, 6]
Sample Input 2:
5
1
11
13
21
19
Sample Output 2:
[1, 11, 21, 19]
Ordered Matrix
Given a M x N matrix, write a program to print the matrix after ordering all the elements of the matrix in increasing order.Input
The first line of input will contain two space-separated integers, denoting the M and N.
The next M following lines will contain N space-separated integers, denoting the elements of each list.Output
The output should be M lines containing the ordered matrix.
Note: There is a space at the end of each line.Explanation
For example, if the given M is 3 and N is 3, read the inputs in the next three lines if the numbers given in the next three lines are the following.
1 20 3
30 10 2
5 11 15By ordering all the elements of the matrix in increasing order, the ordered matrix should be
1 2 3
5 10 11
15 20 30Sample Input 1
3 3
1 20 3
30 10 2
5 11 15
Sample Output 1
1 2 3
5 10 11
15 20 30
Sample Input 2
2 5
-50 20 3 25 -20
88 17 38 72 -10
Sample Output 2
-50 -20 -10 3 17
20 25 38 72 88
Zig-zag order in matrix;;
Input:---
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
Output :--
1 2 3 4 5 6 7 8 9 10 11 12 16 15 14 13
Input 2:---
3 4
1 2 3 4
10 11 12 5
9 8 7 6
Output 2:--
1 2 3 4 5 12 11 10 9 8 7 6
s = input()
s = s.lower()
s2 = s.split()
s3 = ''.join(s2)
if s3 == s3[::-1]:
print("True")
else:
print("False")In this python program it has three test cases, in this three test cases two test cases are getting expected output and third test case are not getting expected output. Please give me expexted output for three test cases. Thank you !
Question url :-
https://drive.google.com/file/d/1ZELb2KSvV36MM4kiF-dTFTC43CeUiFH9/view?usp=sharing
Test case - 1
Input
No lemon no melon
Output
True
Test case - 2
Input
Race Cars
Output
False
Test case - 3
Input
God’s Dog
Output
True
num = int(input())
if num > 1:
for i in range(2, int(num/2)+1):
if (num % i) == 0:
print(True)
break
else:
print(False)
else:
print(True)In this python program it has three test cases, in this three test cases two test cases are getting expected output and third test case are not getting expected output. Please give me expexted output for three test cases. Thank you !
Question url :-
https://drive.google.com/file/d/1XrSRAXys8kKSTYMSm58aED455XD_i4tm/view?usp=sharing
Test case - 1
Input
12
Output
True
Test case - 2
Input
3
Output
False
Test case - 3
Input
1
Output
False
List Indexing - 3
Given N numbers, and an index, write a program to store the numbers in a list and print the number at given index. For this problem, each input will contain T test cases. Each test case will give an index Ki as input, which should be considered to print the number.
Input:
The first line of input is an integer N. The second line of input is an integer T representing the number of test cases. The next N lines contain integers representing the numbers of the list. The next T lines contain integer Ki for each line.
Output:
You need to print a number in a new line for each of the K test cases.
In the given example, we are given
4 numbers 1, 2, 3, 4 as input For the first test case, K=0, the number at 0th index is 1. For the second test case, K=3, the number at 3rd index is 4. So, the output should be
1
4
Sample Input 1
4
2
1
2
3
4
3
Sample Output 1
1
4
Sample Input 2
3
1
13
21
19
Sample Output 2
13
Create and Print List -3:
You are given N numbers as input. Create a list and add the N numbers which are given as input and print the list.
The first line of input is an integer N. The next N lines each contain an integer.
Explanation:
In the given example,
N=4 and the numbers are 1, 2, 3, 4. So, the output should be [ 1, 2, 3, 4 ]
Sample Input 1
4
1
2
3
4
Sample Output 1
[1, 2, 3, 4]
Sample Input 2
3
13
21
19
Sample Output 2
[13, 21, 19]
Acronyms:
You are given some abbreviations as input. Write a program to print the acronyms separated by a dot(.) of those abbreviations.
Input:
The first line of input contains space-separated strings.
Consider the given abbreviation,
Indian Administrative Service. We need to consider the first character in each of the words to get the acronym. We get the letter I from the first string Indian, we get the letter A from the second word Administrative, and we get the letter S from the third word Service. So, the final output should be I.A.S.
Sample Input 1:
Indian Administrative Service
Sample Output 1:
I.A.S
Sample Input 2:
Very Important Person
Sample Output 2:
V.I.P