given a list of M numbers and a positive integer N, print the sum of numbers whose position in the list is divisible by N .consider that the position of numbers range from 1 to N
INPUT:
the first line contains two space-separated integers N, M
the second line contain M space-separated integers.
output:
print a single integer representing the required sum
explanation:
Sample Output1
Given N=1 , M=7
and the number list = [4,8,6,6,7,9,3]
As every position is divisible by 1,
4+8+6+6+7+9+3=43
so the output should be 43
Family List:
A list of words is called the Family if the words in the list follow the following rule.
we should be able to obtain each word in the list by
-changing exactly one letter from the previous word in the list
-or , by adding exactly one letter to the previous word in the list
-or ,by removing exactly one letter from the previous word in the list
Given a list of words ,determine if the list is a Family or Not a Family
input:
The first line of input is an integer T representing the number of test cases
the first line of each test case has an integer N representing the total number of words
The second line contains N space separated strings
INPUT:
3
3
hip hop top
3
hip top hop
4
teat treat greet meet
output:
family
not a family
not a family
i/p:
3
3
tic tac toe
2
tic tac
3
tet treat greet
o/p:
not a family
family
not a family
Note:please display the output
Note:Error is displaying in this code, please correct it
Enter the number of societies:Keep the number of people in societies:
Traceback (most recent call last):
File "main.py", line 4, in <module>
num_people = int(input('Keep the number of people in societies:'))
ValueError: invalid literal for int() with base 10: '\r'
Write a program in Python programming language, which allows the user to input an integer value. Based on the input values, the program should perform the following tasks:
⦁ If the entered value is negative then it should print “Factorial does not exist for negative numbers”.
⦁ If the entered value is 0 then it should print “The factorial of 0 is 1”.
⦁ Calculate and display the factorial of the given integer.
Write a program in Python programming language, which allows the user to input a number and upper limit, and based on the input values, the program should perform the following tasks:
⦁ Check whether the value entered by the user is a positive integer.
⦁ Generates an error massage in case of negative integer.
⦁ Generate a table of given number.
⦁ Upper limit for table will be get from user.
Given a string in camel case,write a program to convert the given string from camel case to snake case...
example:
if the given word is "PythonLearning" in camel case.,your code should print given word in snake case "Python_Learning"...
write a program to find the first prime number in the given inputs
first place
the ouput should be single line containing the ones place of positive integer
input 1:25
ouput:5
input 2:200
output:0
first and last digit
output:print the first digit in first line and second digit in second line
input 1:1456
output:1
6
input 2:9821
output:9
1
write a program to print numbers from 1 to n in each row forming a rectangular pattern of m rows and n columns using numbers