-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession F3 - Operators and Operands.py
56 lines (37 loc) · 1.48 KB
/
Session F3 - Operators and Operands.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Program to calculate area of a rectangle
# def RectangleArea():
# length = int(input("Please enter the length: "))
# breadth = int(input("Please enter the breadth: "))
# area = length * breadth
# print(f"The area of the rectangle is {area}cm\u00b2")
#RectangleArea()
# String slicing
# String slicing returns a range of characters from a string. This is achieved by
# specifying the start index and end index separated by a colon
MyString = "Julius Rice is the man in charge of the program"
print(MyString[:20])
FirstName = "Julius"
LastName = "Alex"
print(FirstName[:3] + LastName[:3]) # concatenate parts of a string
text = "String slicing return a range of character from a string."
print(text[16:]) # returns characters from index 16 to the end
MyString = "The world has turned a big connected domain of data with the massive development of the internet of things. Now we are all in a single global community."
first3 = MyString[0:3]
print(first3)
next5 = MyString[4:10]
print(next5)
print(first3 + " " + next5)
myVar = "This is a Data Analysis Class"
myVar.lower()
print(myVar.upper())
print(myVar.lower())
SampleText = "This is a data analysis class"
print(len(SampleText))
IAmCountingString = "Think Employment Bootcamp"
print ("Data" in IAmCountingString)
a = 5 #assignment operator
5 + 5 #addition
5 - 5 # subtraction
10 / 4 #division
10 % 2 #modulus gives remainder only
11 / 3 #drops remainder