-
Notifications
You must be signed in to change notification settings - Fork 0
/
datatypes.py
39 lines (29 loc) · 1.02 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
# Numbers
# Integers
my_age = 10
print(type(my_age))
# Floats
my_height = 6.0
print(type(my_height))
sum = my_age + my_height
print(type(sum))
# Strings
my_school = 'Digikids' # strings are surrounded by single or double quotes
print(type(my_school))
my_sentence = "I'm a student at Digikids"
print(type(my_sentence))
my_name = 'John'
print('Hello ' + my_name) # concatenation addition of strings
print(str(my_age) + my_name) # str() converts a number to a string
print(2 * my_name) # multiplication of strings
# 1. Write a code to create a new integer variable and
# store your favorite number in it.
# 2. Write a code to create a new float variable and
# store the value of pi with two decimal places. pi = 3.14
# 3. Write a code to add two floating-point numbers and
# store the result in a new variable.
# 4. Write a code to create a new string variable and
# store your name.
# 5. Write a code to print a sentence that includes your
# name and your favorite number, using the variables you created in
# questions 1 and 4.