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 / s04q01-solution.py
Last active August 17, 2018 20:11
alert action based on tank's current level
''' alert action based on tank's current level '''
# input tank current level
def input_current_level():
return float(input("Please input current level of tank in liters: "))
# tank capacity calculator in percentage
def capacity_percentage_calculator():
current_level = input_current_level()
percentage = ((current_level)*100)/900
@Ojha-Shashikant
Ojha-Shashikant / s04q02-solution.py
Last active August 17, 2018 20:11
percentage and rank of student based on marks scored in various subjects
''' percentage and rank of student based on marks scored in various subjects '''
# function to input marks in english
def input_english_marks():
english_marks = float(input("provide the marks scored english:" ))
if english_marks > 80:
print("Maximum marks in english is 80, please enter proper value")
english_marks = float(input("provide the marks scored in english:" ))
return english_marks
else:
@Ojha-Shashikant
Ojha-Shashikant / s03q02-solution.py
Last active August 17, 2018 20:12
Printing unit places of the number input as per the number of digits
''' Printing unit places of the number input as per the number of digits '''
# user input function
def number_input():
return int(input("Please input any digit integer of your choice: "))
# calculating number of digits
def digit_calculator(num):
digit_count = 0
#print (num)
@Ojha-Shashikant
Ojha-Shashikant / s03q01-solution.py
Last active August 17, 2018 20:12
Printing if number is 2-digit or 3-digit
''' Printing if number is 2-digit or 3-digit '''
# user input function
def number_input():
return int(input("Please input any digit integer of your choice: "))
# calculating number of digits
def digit_calculator(num):
digit_count = 0
#print (num)
@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:
@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 / 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: