Posts

Showing posts with the label language fundamentals

Add the Index Python Programming

Image
Problem:- Given a list of numbers, create a function that returns the list but with each element's index in the list added to itself. This means you add 0 to the number at index 0, add 1 to the number at index 1, etc... Examples:- add_indexes([0, 0, 0, 0, 0]) ➞ [0, 1, 2, 3, 4] add_indexes([1, 2, 3, 4, 5]) ➞ [1, 3, 5, 7, 9] add_indexes([5, 4, 3, 2, 1]) ➞ [5, 5, 5, 5, 5] Code:-  Note:- Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.

Characters in Shapes Python Programming

Image
Problem:- Create a function to calculate how many characters in total are needed to make up the shape. You will be given a list of strings that make up a shape in the compiler (i.e. a square, a rectangle, or a line). Examples:- count_characters([   "###",   "###",   "###" ]) ➞ 9 count_characters([   "22222222",   "22222222", ]) ➞ 16 count_characters([   "------------------" ]) ➞ 18 count_characters([]) ➞ 0 count_characters(["", ""]) ➞ 0 Code:- Note:- Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.