-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatatypes.py
51 lines (42 loc) · 1.14 KB
/
datatypes.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
import numpy as np
import pandas as pd
# Declaring Variables
age = 30 # integer
name = "Wanjala" # character
height = 5.9 # float
is_student = True # Boolean
print("Age:", age)
print("Name:", name)
print("Height:", height)
print("Is_student:", is_student)
# Check data types
print("Type of Age:", type(age))
print("Type of Name:", type(name))
print("Type of Height:", type(height))
print("Tpye of Is_student:", type(is_student))
age_str = str(age)
height_int = int(height)
is_student_int = int(is_student)
print("Age as string:", age_str)
print("Height as integer:", height_int)
print("Is_student as integer:", is_student_int)
# String manipulation
# string contenation
full_name = name + "Joel"
print("Full Name:", full_name)
# String formatting
introduction = f"My name is {name}, I am {age} years old."
print(introduction)
# String methods
print("Upper Case Name:", name.upper())
print("Name length:", len(name))
# Arithmetic operations
x = 999
y = 455
print("Addition:", x + y)
print("Subtraction:", x - y)
print("Multiplication:"(), x * y)
print("Division:", x / y)
print("Floor Division:", x + y)
print("Modulus:", x % y)
print("Exponentiation:", x ** y)