Похожие презентации:
Lesson 13 STR Slice
1.
STR Slicing2.
Naming ConventionsUse the Task Name
Generate a Masked Credit Card Number
Name file: Generate_a_Masked_Credit_Card_Number
3.
Generate_a_Masked_Credit_Card_NumberWrite a program that takes a credit card number as input (a string of 16 digits) and returns a masked version where only the last four
digits are visible. The rest should be replaced with *. If the input is not 16 digits, print "Invalid card number".
INPUT: 1234567812345678
OUTPUT: ************5678
4.
Find Words That Contain a Specific Letter in a ListWrite a program that takes a list of words and a letter. Find all words that contain the letter at least twice and store them in a new list. If
no words match the criteria, print "No words found".
words = ["banana", "apple", "cherry", "grape"]
letter = "a"
OUTPUT: ['banana', 'apple']
5.
Find the Longest Word in a ListWrite a program that takes a list of words and finds the longest one using string
slicing and if conditions. If two words have the same length, return the first one
that appears in the list.
words = ["apple", "banana", "cherry", "blueberry"]
OUTPUT: The longest word is blueberry.
6.
Capitalize Every Alternate Word in a SentenceWrite a Python program that takes a sentence and capitalizes every alternate word, starting from the first. If the sentence has less than
two words, print "Too short to modify".
INPUT:
sentence = "python is a great programming language"
OUTPUT: "Python is A great Programming language"
7.
Removing Duplicates from a ListWrite a Python program that removes duplicate values from a list while
maintaining the original order.
Example Input: [1, 2, 2, 3, 4, 4, 5]
OUTPUT: [1, 2, 3, 4, 5]
Программирование