-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.py
More file actions
56 lines (40 loc) · 1.17 KB
/
variables.py
File metadata and controls
56 lines (40 loc) · 1.17 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
# Let's create a variable
# print('Hello world')
x = 10 # type of integer
y = 3.6 # float
string = "Sparta_" # String
print(x)
print(y)
print(x + y)
# builtin method called type() to find what kind of variable it is
print(type(y))
print(str(x) + string) # you cannot combine string with an integer so turn the integer into a string
age = 99
NHS = 123455
string = 'Sparta'
salary = 50000
name = input("Please enter your name")
print(name)
# Overriding variables
name = "james"
print(name)
name = "Christine"
print(name)
# Exercise: Capturing user details
# Create a variable called first_name and last_name
first_name = "Kenneth"
last_name = "Leith"
print(first_name)
print(last_name)
# Create a variable called full_name and display full_name
full_name = first_name + ' ' + last_name
print(full_name)
# Create a variable called age
age = 65
print(age)
# Create a variable called address
address = "3 Tennant House"
print(address)
# Prompt the user to display all the information
print("Hello" + " " + full_name + ', ' + "you are" + " " + str(age) + " " + "years old and you live at" + " " + address)
# Returns Hello Kenneth Leith, you are 65 years old and you live at 3 Tennant House