forked from Khens96/Python_Fundamentals101
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_syntax_exercise.py
More file actions
91 lines (60 loc) · 2.63 KB
/
basic_syntax_exercise.py
File metadata and controls
91 lines (60 loc) · 2.63 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
85
86
87
88
89
90
91
# Python Basic Syntax
# 1. Variables: You can store values in variables.
# On the next line store the number '10' in the variable 'x'.
# On the next line, store the number '20.5' in the variable 'y'.
# On the next line, store the string 'Hello, World!' in the variable 'z'.
# On the next line, store the boolean 'True' in the variable 'a'.
# On the next line, store the boolean 'False' in the variable 'b'.
# Use the print statement and the variable 'x' to display the message:
# "10, is an integer variable."
print()
# Use the print statement and the variable 'y' to display the message:
# "20.5, is a float variable."
print()
# Use the print statement and the variable 'z' to display the message:
# " 'Hello, World!' is a string variable."
print()
# Use the print statement and the variable 'a' to display the message:
# " 'True', is a boolean variable."
print()
# Use the print statement and the variable 'b' to display the message:
# " 'False', is a boolean variable.
print()
# 2. Data Types: Python has several built-in data types.
# Use the `type()` function to identify the data types of your variables.
# Usage example:
# h = 13
# print(type(h)) will display <class 'int'>
# Edit the code below to print:
# "10 belongs to <class 'int'>: meaning it is an integer."
print()
# Edit the code below to print:
# " 20.5 belongs to <class 'float'>: meaning it is a float."
print()
# Edit the code below to print:
# " 'Hello, World!', belongs to <class 'str'>: meaning it is a string."
print()
# Edit the code below to print:
# "'True', belongs to <class 'bool'>: meaning it is a boolean."
print()
# Edit the code below to print:
# "'False', belongs to <class 'bool'>: meaning it is a boolean.
print()
# 3. Basic Operators:
# Python supports various operators for performing operations on data.
# Arithmetic Operators
# Addition: print the sum of 'x' and 'y'.
print("The sum of 'x' and 'y' is: ")
# Subtraction: print the difference between 'x' and 'y'.
print("The difference between 'x' and 'y' is: ")
# Multiplication: print the product of 'x' and 'y'.
print("The product of 'x' and 'y' is: ")
# Division: print the answer when you divide 'x' by 'y'.
print("The division of 'x' by 'y' is:")
# Modulus (remainder of the division): print the remainder after dividing 'x' by 'y'.
print("The modulus of 'x' and 'y' is: ")
# 4. Indentation:
# Python uses indentation to indicate the beginning and end of code blocks.
# Complete the for loop below to print numbers 0 to 5
# for number in range(6):
# print() # This line is part of the for loop and it must be indented.