You can learn about Introduction to Python Programming Programs with Outputs helped you to understand the language better.
Python Programming – Simple Python Programs
Program to ac,d two numbers given by the user.
# Program to add two numbers given by user print ( ‘ Please enter an integer value: ‘ ) x = input ( ) print ( ‘ Please enter another integer value: ‘ ) y = input ( ) numl = int(x) mm2 = int (y) print (numl, ‘ + ‘, mm2, ‘=’, num1 + num2) Introduction to Python 77 Module 3: M3-R5 RUN >>> Please enter an integer value: 56 Please enter another integer value: 32 56 + 32 = 88 >>> |
- Python Programming – Print Statement
- Python Programming – Variable
- Python Programming – How To Start Python
Program to display moths and days for enterd no.of days.
# Program to display moths and days for enterd no.of days. a days = int(input(“Enter days: “)) months = days / 30 days = days5% 30 print ( ”Months = ”, int ( Month) , ”Days = ”, days)RUN >>> Enter days: 365 Months = 12 days >>> |
Program to find selling price.
#Program to find selling price costprice=int ( input ( ” Enter Cost Price: ” ) ) profit=int ( input ( ” Enter profit: ” ) ) sellingprice = costprice+profit print (“Selling price: “,sellingprice)RUN >>> Enter Cost Price: 100 Enter profit: 20 Selling price: 120 >>> |
program to calculate Bonus, Commission and Gross salary.
# Program to calculate Bonus, Commission and Gross salary basic_salary = 1500 bonus_rate = 200 commision_rate = 0.02 sold = int(input(“Enter the number of inputs sold: “)) price = float(input(“Enter the total prices: “)) bonus = (bonus_rate * sold) commission = (commision_rate * sold * price) print(“Bonus = %6.2f” % bonus) print(“Commision = %6.2f” % commission) print(“Gross salary = %6.2” % (basic_salary + bonus + commission) )RUN >>> Enter the number of inputs sold: 2 Enter the total prices: 5 Bonus = 400.00 Commission = 0.20 Gross salary = 1900.20 >>> |
Program to convert the time given into minutes in hours and minutes.
# Program to convert the time given in minutes in hours and minutes time = int(input(“Enter time in minutes: “)) hours= time/60 minutes = time%60 print(“Hours : “, round(hours)) print(“Minutes minutes)RUN >>> Enter time in minutes: 70 Hours: 1 Minutes: 10 >>> |
- Python 2 has two versions of input functions, input( ), and raw_input(). The input( ) function treats the received data as a string if it is included in quotes ” or otherwise the data is treated as a number. In Python 3, raw_input() function is deprecated. Further, the received data is always treated as a string.
Refer More: