Flash Cards - Strings

Description

Flashcards on Flash Cards - Strings, created by Aparna Dhirde on 17/03/2020.
Aparna Dhirde
Flashcards by Aparna Dhirde, updated more than 1 year ago
Aparna Dhirde
Created by Aparna Dhirde over 4 years ago
58
0

Resource summary

Question Answer
Sequence data types in Python Strings, Lists and Tuples
Strings String is a sequence which is made up of one or more UNICODE characters. Here the character can be a letter, digit, whitespace or any other symbol. A string can be created by enclosing one or more characters in single, double or triple quote.
String is Immutable It means that the contents of the string cannot be changed after it has been created.
String Operations Concatenation,Repetition,Membership and Slicing
Concatenation to join two strings using concatenation operator plus which is denoted by symbol +.
Repetition to repeat the given string using repetition operator which is denoted by symbol *.
Membership Python has two membership operators 'in' and 'not in'. The 'in' operator takes two strings and returns True if the first string appears as a substring in the second string, otherwise it returns False.
Slicing to access some part of a string or substring,
Built-in Functions functions whose functionality is pre-defined in Python.
len() Returns the length of the given string
title() Returns the string with first letter of every word in the string in uppercase and rest in lowercase
lower() Returns the string with all uppercase letters converted to lowercase
upper() Returns the string with all lowercase letters converted to uppercase
count(str, start, end) Returns number of times substring str occurs in the given string. If we do not give start index and end index then searching starts from index 0 and ends at length of the string
find(str,start,end) Returns the first occurrence of index of substring str occurring in the given string. If we do not give start and end then searching starts from index 0 and ends at length of the string. If the substring is not present in the given string, then the function returns -1
endswith() Returns True if the given string ends with the supplied substring otherwise returns False
startswith() Returns True if the given string starts with the supplied substring otherwise returns False
isalnum() Returns True if characters of the given string are either alphabets or numeric. If whitespace or special symbols are part of the given string or the string is empty it returns False
islower() Returns True if the string is non-empty and has all lowercase alphabets
isupper() Returns True if the string is non-empty and has all uppercase alphabets
isspace() Returns True if the string is non-empty and all characters are white spaces (blank, tab, newline, carriage return)
istitle() Returns True if the string is non-empty and title case, i.e., the first letter of every word in the string in uppercase and rest in lowercase
lstrip() Returns the string after removing the spaces only on the left of the string
rstrip() Returns the string after removing the spaces only on the right of the string
strip() Returns the string after removing the spaces both on the left and the right of the string
replace(oldstr,newstr) Replaces all occurrences of old string with the new string
join() Returns a string in which the characters in the string have been joined by a separator
split() Returns a list of words delimited by the specified substring. If no delimiter is given then words are separated by space.
Show full summary Hide full summary

Similar

The USA, 1919-41
sagar.joban
Mapa Mental - Como Criar um Mapa Mental
miminoma
Jekyll and Hyde
elliesussex
Diffusion and osmosis
eimearkelly3
IMPERFECT TENSE - French
T W
GCSE History of Medicine: Key Individuals
James McConnell
Memory - AQA Psychology Unit 1 GCSE
joshua6729
Cognitive Psychology Key Terms
Veleka Georgieva
The Biological basis of Heart Disease
Andrea Leyden
Graphing Inequalities
Selam H
GCSE Geography - Causes of Climate Change
Beth Coiley