Skip to content

Instantly share code, notes, and snippets.

View Ojha-Shashikant's full-sized avatar

Ojha-Shashikant

View GitHub Profile
@Ojha-Shashikant
Ojha-Shashikant / s01q01-solution.py
Last active August 17, 2018 20:02
Taking name as input and displaying Hello with name
"""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()
@Ojha-Shashikant
Ojha-Shashikant / s01q02-solution.py
Last active August 17, 2018 20:07
Multiplication table of 17
'''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)
@Ojha-Shashikant
Ojha-Shashikant / s01q03-solution.py
Last active August 17, 2018 20:10
Multiplication table of integer input by user
'''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()
@Ojha-Shashikant
Ojha-Shashikant / s02q01-solution.py
Last active August 17, 2018 20:33
calculating car's mileage using starting and ending values of odometer
''' 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:
@Ojha-Shashikant
Ojha-Shashikant / s02q02-solution.py
Last active August 17, 2018 20:33
Calculating number of stops from Bangalore to Goa
''' 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: "))
@Ojha-Shashikant
Ojha-Shashikant / s01aq01-solution.py
Last active August 17, 2018 20:15
""" Using functions taking name as input and displaying Hello with name """
""" 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())
@Ojha-Shashikant
Ojha-Shashikant / s01aq02-solution.py
Last active August 17, 2018 20:14
Using functions multiplication table of 17
'''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
@Ojha-Shashikant
Ojha-Shashikant / s01aq03-solution.py
Last active August 17, 2018 20:14
Using functions multiplication table of integer input
'''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:
@Ojha-Shashikant
Ojha-Shashikant / s02aq02-solution.py
Last active August 17, 2018 20:13
Using functions calculating number of stops from Bangalore to Goa
''' 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:
@Ojha-Shashikant
Ojha-Shashikant / s02aq01-solution.py
Last active August 17, 2018 20:13
Using functions calculating car's mileage using starting and ending values of odometer
''' 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: