Strings= capitalize
Example 1:
first number=5
second number=6
answer= first number + second number
print (answer)
Example 2:
a=name. CAPITALIZE()
b=name. UPPER()
c=name. lower()
d=name. string()
Index; the ability to find words in a set of letters
if=0
N/B: the spaces in a python letters are counted as zeros, while number are counted
from one
Example 3:
F A V O U R B A S S E Y
0 1 2 3 4 5 6 7 8 9 10 11 12 13
#Working with element
a1=name[10] S
a2=name[2] A
a3=name[13] Y
Vsay; variable name
Vsay=a1+a2+a3
Print(Vsay)
=SAY
List allows you to store a lot of values
Example 4:
list_of_numbers=[1,2,33,45,87,90,100]
p1=list_of_numbers[3]
p2=list_of_numbers[5]
p3=p1+p2
print[p3]
ASSIGNMENT
1. Create a variable called 'course' and assign a string name. INFORMATION AND
MEDIA STUDIES. Generate the following output
a. Form
b. Dies
c. Rat
d. Onions
e. Room
f. Insert
g. Student
h. Sat
I. Format
j. Did
k. Store
l. Or
2. Generate list of words that has [I,AM,GOOD,AT,INFORMATION]
a. Using a list words
b. Use the method 'sort'
c. Print the sorted value
ANSWERS
1. I N F O R M A T I O N A N D M E D I A S T U D I
E S
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
27 28 29
A. #Working with index
a1=name[3]
a2=name[4]
a3=name[5]
a4=name[6]
Course= a1+a2+a3+a4
Print(course)
answer= FORM
B. #Working with index
a1=name[5]
a2=name[7]
a3=name[8]
Course= a1+a2+a3
Print(course)
Answer= RAT
C. #Working with index
a1=name[26]
a2=name[27]
a3=name[28]
a4=name[29]
Course=a1+a2+a3+a4
Print(course)
Answer=DIES
D. #Working with index
a1=name[10]
a2=name[11]
a3=names[27]
a4=names[4]
a5=name[11]
a6=name[29]
Course=a1+a2+a3+a4+a5+a6
Print(course)
Answer= ONIONS
E. #Working with index
a1=name[5]
a2=name[4]
a3=name[10]
a4=name[17]
Course=a1+a2+a3+a4
print(course)
Answer=ROOM
F. #Working with index
a1=name[01]
a2=name[02]
a3=name[23]
a4=name[18]
a5=name[05]
a6=name[08]
Course=a1+a2+a3+a4+a5+a6
Print(course)
Answer=INSERT
G. #Working with index
a1=name[29]
a2=name[24]
a3=name[25]
a4=name[15]
a5=name[18]
a6=name[11]
a7=name[08]
Course=a1+a2+a3+a4+a5+a6+a7
Print(course)
Answer=STUDENT
H. #Working with index
a1=name[23]
a2=name[14]
a3=name[24]
Course=a1+a2+a3
Print(course)
Answer=SAT
I. #Working with index
a1=name[03]
a2=name[10]
a3=name[05]
a4=name[06]
a5=name[07]
a6=name[08]
Course=a1+a2+a3+a4+a5+a6
Print(course)
Answer=FORMAT
J. #Working with index
a1=name[15]
a2=name[20]
a3=name[19]
Course=a1+a2+a3
Print(course)
Answer=DID
K. #Working with index
a1=name[24]
a2=name[25]
a3=name[06]
a4=name[07]
a5=name[18]
Course=a1+a2+a3+a4+a5
Print(course)
Answer=STORE
L. #Working with index
a1=name[04]
a2=name[05]
Course=a1+a2
Print(course)
Answer=OR