This file contains 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
"""Taking name as input and displaying Hello with name""" | |
# input function for name | |
def input_name(): | |
name = input("What is your name? ") | |
return name | |
# main function | |
def main(): | |
n = input_name() |
This file contains 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
'''Multiplication table of 17''' | |
# main function | |
def main(): | |
for i in range(1, 11): | |
if i == 10: | |
print("17*", i, "=", 17*i) | |
else: | |
print("17*", i, " =", 17*i) |
This file contains 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
'''Multiplication table of integer input by user''' | |
# integer input function | |
def input_integer(): | |
i = int(input("Provide an integer whose multiplication table required: ")) | |
return i | |
# main function | |
def main(): | |
intgr = input_integer() |
This file contains 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
''' calculating car's mileage using starting and ending values of odometer''' | |
# odometer reading starting, ending values and calculating the difference | |
def odometer_reading_difference(): | |
starting_value = float(input("Provide odometer trip starting value in Kms: ")) | |
ending_value = float(input("Provide odometer trip ending value in Kms: ")) | |
if ending_value < starting_value: | |
print("Starting value cannot be greater than ending value") | |
exit() | |
elif ending_value == starting_value: |
This file contains 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
''' calculating number of stops from Bangalore to Goa ''' | |
'''???Need to understand how to use a value already found in one function into another function. In this case how to use | |
... already known mileage and unit cost of fuel, could have written in a different way. Function number_of_stops is | |
... lengthy because of my knowledge limitation''' | |
# odometer reading starting, ending values and calculating the difference | |
def odometer_reading_difference(): | |
starting_value = float(input("Provide odometer trip starting value in Kms: ")) | |
ending_value = float(input("Provide odometer trip ending value in Kms: ")) |
This file contains 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
""" Using functions taking name as input and displaying Hello with name """ | |
# input function for name | |
def input_name(): | |
name = input("What is your name? ") | |
return name | |
# display function | |
def display(): | |
print("Hello", input_name()) |
This file contains 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
'''Using functions multiplication table of 17''' | |
# multiplication table | |
def mult_table(): | |
i=1 | |
while i<=10: | |
print("17*", i, "=", 17*i) | |
i += 1 | |
# main function |
This file contains 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
'''Using functions multiplication table of integer input''' | |
# input function | |
def input_integer(): | |
return int(input("Provide integer whose table is required: ")) | |
# multiplication table | |
def mult_table(num): | |
i=1 | |
while i<=10: |
This file contains 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
''' Using functions calculating number of stops from Bangalore to Goa ''' | |
# odometer reading starting, ending values and calculating the difference | |
def odometer_reading_difference(): | |
starting_value = float(input("Provide odometer trip starting value in Kms: ")) | |
ending_value = float(input("Provide odometer trip ending value in Kms: ")) | |
if ending_value < starting_value: | |
print("Starting value cannot be greater than ending value") | |
exit() | |
elif ending_value == starting_value: |
This file contains 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
''' Using functions calculating car's mileage using starting and ending values of odometer''' | |
# odometer reading starting, ending values and calculating the difference | |
def odometer_reading_difference(): | |
starting_value = float(input("Provide odometer trip starting value in Kms: ")) | |
ending_value = float(input("Provide odometer trip ending value in Kms: ")) | |
if ending_value < starting_value: | |
print("Starting value cannot be greater than ending value") | |
exit() | |
elif ending_value == starting_value: |
OlderNewer