Posts

Showing posts with the label numbers

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.

Hiding the Card Number Python Programming

Image
Problem:- Write a function that takes a credit card number and only displays the last four characters. The rest of the card numbers must be replaced by ************. Example:- card_hide("1234123456785678") ➞ "************5678" card_hide("8754456321113213") ➞ "************3213" card_hide("35123413355523") ➞ "**********5523" code:- Note:- Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.

Folding a Piece of Paper Python Programming

Image
Problem: -  Create a function that returns the thickness (in meters) of a piece of paper after folding it n number of times. The paper starts off with a thickness of 0.5mm. Example:- num_layers(1) ➞ "0.001m" # Paper folded once is 1mm (equal to 0.001m) num_layers(4) ➞ "0.008m" # Paper folded 4 times is 8mm (equal to 0.008m) num_layers(21) ➞ "1048.576m" # Paper folded 21 times is 1048576mm (equal to 1048.576m) Code:- Note:- Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.