题目: Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 解题方法: 很简单的题目: de…
题目: Complete the square sum function so that it squares each number passed into it and then sums the results together. For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9. 解题方法:(再想想可能就出来了) def square_sum(numbers): return sum(map…
题目: When you sign up for an account somewhere, some websites do not actually store your password in their databases. Instead, they will transform your password into something else using a cryptographic hashing algorithm. After the password is transfo…
题目: Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor. Example divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6] 解题方法:…
题目: Consider an array of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [True, True, True, False, True, True, True, True , True, False…
题目: In this simple exercise, you will create a program that will take two lists of integers, a and b. Each list will consist of 3 positive integers above 0, representing the dimensions of cuboids a and b. You must find the difference of the cuboids'…
题目: Create a method that takes an array/list as an input, and outputs the index at which the sole odd number is located. This method should work with arrays with negative numbers. If there are no odd numbers in the array, then the method should outpu…
题目: Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are the Even numbers and Boys are the odd   Task Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from t…
题目: Modify the spacify function so that it returns the given string with spaces insertedbetween each character. spacify("hello world") # returns "h e l l o w o r l d" 解题办法: def spacify(string): #your code here return ' '.join(list(stri…
题目: You are given an input string. For each symbol in the string if it's the first character occurence, replace it with a '1', else replace it with the amount of times you've already seen it... But will your code be performant enough? Examples: input…