This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def main(a, b): | |
if a > b: | |
print("A is greater than b.") | |
elif a == b: | |
print("A is equal to b") | |
else: | |
print("A is less than b") | |
if __name__ == "__main__": | |
main(5, 10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def forecast(rain_chance, temp): | |
if rain_chance >= 60 and temp > 70: | |
print( | |
f"With a {rain_chance}% chance of rain today, don't forget your umbrella!") | |
elif rain_chance <= 30 and temp < 80 and temp > 60: | |
print("Enjoy the beautiful weather today") | |
elif rain_chance >= 60 and temp < 40: | |
print("Its going to be a cold and wet day today. Dress appropriately and be safe out there.") | |
elif rain_chance == 0 and temp < 40: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tally_nums(*numbers): | |
total = 0 | |
for n in numbers: | |
total += n | |
print(total) | |
if __name__ == "__main__": | |
tally_nums(1, 1, 1.3, 4.6) | |
tally_nums(4, 5, 6, 7, 8, 9) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def tally_nums(*numbers): | |
total = 0 | |
for n in numbers: | |
total += n | |
print(total) | |
if __name__ == "__main__": | |
tally_nums(1, 1, 1.3, 4.6) | |
tally_nums(4, 5, 6, 7, 8, 9) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square(num): | |
answer = num * num | |
print(answer) | |
square(2) | |
square(4) | |
square(6) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Python: Current File", | |
"type": "python", | |
"request": "launch", | |
"program": "${file}", | |
"console": "internalConsole" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a comment. Comments start with the '#' | |
# Function one (for demonstration purposes) | |
def function_name(parameter): | |
#This is the functions body | |
#The body is defined by the indention at the begining of the line | |
print(parameter) | |
# Function two | |
def function_two(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
attr_accessor :color, :year, :make, :model | |
@@all = [] | |
def initialize(color, year, make, model) | |
@color = color | |
@year = year | |
@make = make | |
@model = model | |
@@all << self | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
attr_accessor :color, :year, :make, :model | |
def initialize(color, year, make, model) | |
@color = color | |
@year = year | |
@make = make | |
@model = model | |
end | |
def get_vin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car | |
attr_accessor :color, :year, :make, :model | |
def initialize(color, year, make, model) | |
# our instance variables are defined using a single @ | |
@color = color | |
@year = year | |
@make = make | |
@model = model | |
end | |