-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables_starter.py
78 lines (51 loc) · 1.6 KB
/
variables_starter.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
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
"""
Name:
Title: Math, Variables, User Input, & Types
Description: Working with fundametal data types and operations in Python. Storing data in variables. Interacting with a user.
"""
# VARIABLE:
'''
# Follow all variable naming rules and conventions:
# Rules for legal variable names:
# - Contain only numbers, letters, and underscores
# - Can’t start with a number
# - Can’t be a reserved keyword in Python (print, input, type, etc.)
# Guidelines for good variable names:
# - Be descriptive of a variable's contents
# - Be consistent with formatting
# - Follow conventions:
# - names that begin with an underscore have a special meaning
# - don’t begin with a capital letter
# - Consider the trade-off of long names
'''
# ASSIGNMENT STATEMENT:
# ASSIGNMENT OPERATOR:
# INPUT function -
# CONCATENATION:
# string repetition
# Numbers types in Python - 2 new TYPES:
# INTEGER(int) -
# FLOATING POINT NUMBER (float) -
# Built-in functions to convert types:
# str() converts to a string
# int() converts to an int
# float() converts to a float
# nesting functions:
input("\n\nPress enter to process calculations...")
print("---------------------------------------")
num1 = 0
num2 = 0
# Math Operators:
# + , - , / , //, * , ** , %
# addition
result = num1 + num2
print(num1, "+", num2, "=", result)
# subtraction
# true (floating point) division
# integer division - leaves off remainder
# multiplication
# exponents
# modulus - gives the remainder
# STATEMENT -
# EXPRESSION -
print("\nThanks for using the Python calculator. Re-run program for new numbers.")