-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython_introduction.py
More file actions
84 lines (58 loc) · 1.24 KB
/
Python_introduction.py
File metadata and controls
84 lines (58 loc) · 1.24 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Python Introduction
print("Hello world!")
name = input("Please enter your name: ")
age = int(input("Please enter your age: "))
print(type(age))
print(name)
print(age)
# BIDMAS
# 1st 2 x 20
# 2nd Division
# 3rd Addition
# 4th Subtraction
x = 10 / (2 * 20) + 7 - 2
print(x)
# 1st Division
# 2nd Multiplication
# 3rd Addition
# 4th Subtraction
y = 10 / 2 * 20 + 7 - 2
print(y)
# String Manipulation
hello = "Hello World"
#Lower case
print(hello.lower())
#Upper case
print(hello.upper())
# Replace
hellov2 = hello.replace("World", "Everybody")
print(hellov2)
print(hellov2.upper())
#Split
print(hello.split())
# Join
list1 = ["Hello", "World"]
print(" ".join(list1))
# Count
print(hello.count("l"))
# Is there a digit in the text
print(hello.isdigit())
x = "Hello"
age = 28
# Concatinating
print("Victoria" + " " + "Trainer")
# Not Concatinating -> print("Victoria", "Trainer")
print("Victoria" + " " + str(age+10))
# f strings
print(f"This is my age {age}")
# Escape Characters
print('Hello this is \"Victoria\"')
print(f"Person 1: \t {x}, how are you? \nPerson 2: \t Good thanks! \U0001F604")
# Integers and Floats
print(int(3.6))
print(float(3))
#Rounding a number up or down
print(round(3.5739375))
# Booleans
print(4 < 20)
print(4 > 20)