|
Data Type
|
the type of the value
|
|
Variable
|
stores a value
|
|
Identifier
|
name of a variable
|
|
String
|
Sequence of characters
|
“Hello World”
|
|
Integer
|
Whole numbers
|
101
|
|
Float
|
Decimal numbers
|
71.24
|
|
Boolean
|
True or False
|
4 > 3
|
print("Hello" + " World!")price = 2.00print("The apple is " + str(price) + "dollars")|
str()
|
converts a value to a string
|
|
int()
|
converts a value to an integer
|
|
float()
|
converts a value to a float
|
|
bool()
|
converts a value to a boolean
|
|
+
|
Addition
|
|
-
|
Subtraction
|
|
*
|
Multiplication
|
|
/
|
Division
|
num1 = 5
num2 = 3
product = num1 * num2
print("Product:" + str(product))
|
==
|
Checks if the values are equal
|
|
!=
|
Checks if the values are not equal
|
|
>
|
Checks if the left value is greater than the right value
|
|
<
|
Checks if the left value is less than the right value
|
|
>=
|
Checks if the left value is greater than or equal to the right value
|
|
<=
|
Checks if the left value is less than or equal to the right value
|
if grade >= 90:
print("Letter grade: A") if grade >= 90:
print("Letter grade: A") else:
print("You did not get an A") if grade >= 90:
print("Letter grade: A") elif grade >= 80:
print("Letter grade: B") else:
print("Letter grade: unknown")grade_list = [88,90,68,78,89,96,100,40]for grade in grade_list: print(grade)'for x in range(6): print(x)for x in range(1, 6): print(x)for x in range(1, 6, 2): print(x)No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.