Lecture2_py
Lecture2_py
Basic Operations
concatenation
“hello” + “world” “helloworld”
length of str
len(str)
Indexing
Apna_College
0 1 2 3 4 5 6 7 8 9 10 11
str = “Apna_College”
str = “Apple”
str[ -3 : -1 ] is “pl”
String Functions
str = “I am a coder.”
if(condition) :
Statement1 elif(condition):
Statement2 else:
StatementN
Conditional Statements
Grade students based on marks
90 > marks >= 80, grade = “B” 80 > marks >= 70, grade = “C” 70 > marks, grade = “D”
Let‘s Practice
WAP to check if a number entered by the user is odd or even.