Posts

Showing posts with the label Strings

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.

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.

Return the Index of All Capital Letters Python Programming

Image
Problem: -  Create a function that takes a single string as an argument and returns an ordered list containing the indices of all capital letters in the string. Example:- index_of_caps("eDaBiT") ➞ [1, 3, 5] index_of_caps("eQuINoX") ➞ [1, 3, 4, 6] index_of_caps("determine") ➞ [] index_of_caps("STRIKE") ➞ [0, 1, 2, 3, 4, 5] index_of_caps("sUn") ➞ [1] Notes :- Return an empty list if no uppercase letters are found in the string. Special characters ($#@%) and numbers will be included in some test cases. Assume all words do not have duplicate letters. Code:- Note:-  Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.

Xs and Os Nobody Knows Edabit Python Programming

Image
Problem:-  Create a function that takes a string, checks, if it has the same number of "x"s and "o"s, and returns either True or False. Return a boolean value (True or False). Return True if the number of x's and o's are the same. Return False if they aren't the same amount. The string can contain any character. When "x" and "o" are not in the string, return True. Code :- Simple Solustion:-         2. Using dictionary comprehension:- Note:-  Never miss indentation. If you are stuck check the python documentation. Suggestions and comments are always welcome.

Boolean to String Conversion Python Pogramming Problem

Image
Problem:- Create a function that takes a boolean variable flag and returns it as a string. Examples:- boot_to_string(True) -- > "True" boot_to_string(True) -- > "False" Code:-                          Note:- Don't forget indentation.