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
''' 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 |
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
''' 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: |
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
''' 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) |
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
''' 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) |
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: |
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 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: |
OlderNewer