Top 5000 python programs examples with solutions - Part 7
Program 71:
Write a program to form below phrases? using print() function.
I miss you in the morning;
I miss you late at night.
Just to think about you
Is my joy and my delight.
I miss you in the morning;
I miss you late at night.
print("I miss you in the morning; \n\tI miss you late at night. \n\t\tJust to think about you \n\t\tIs my joy and my delight. \nI miss you in the morning; \n\tI miss you late at night.")
Program 72:
Write a program to get print date and time of module?
import datetime dt=datetime.datetime.now() print('DATE and TIME:') print(dt.strftime("%Y-%m-%d,%H:%M:%S"))
Program 73:
Write a program to calculate PI Value using python?
from math import pi r=float(input("Enter the input Value for radius:")) print("PI Calculation:",pi*r**2)
Program 74:
Write a program to get python version ?
import sys print("python version:") print(sys.version) print("python version info:") print(sys.version_info)
Program 75:
Write to export PATH Variable in python?
cd ~ vim .bash_profile export PATH=$PATH:/usr/local/python3/bin source .bash_profile
Program 76:
Write a program to get only extension name of file?
Method1:
user_input=input('Enter IP Filename with extension\n') print(user_input.split('.')[0])
Method 2:
filename = input("Filename: ") counter = 0 for a in filename: counter += 1 if a == ".": b = filename[counter:] print(f"extension of file:",b)
Method 3: filename=input("filename: ") index=filename.find(".") name=filename[index+1:] print(name)
Program 77:
Write a program to print the calendar for given month and year in python?
import calendar year=int(input("Enter the Year")) month=int(input("Enter the Month")) cal=calendar.month(year,month) print(cal)
Program 78:
Write a program to get between days of two dates in python ?
from datetime import date sdate=date(2017,12,1) edate=date(2023,12,1) tdays=edate - sdate print(tdays)
Program 79:
Write a program to get difference between a given number with 17, if the number is greater than 17 return double difference?
var=int(input('enter the input value')) if(var > 17): v=var-17 f=abs(v*5) else: f=abs(17-var) print('The value of final:',f)
Program 80:
Write a program to get with in 1000 or 2000 from input value?
def nearbyvalue(n): return ((abs(1000 - n) <= 100) or (abs(2000 - n) <= 100)) print(nearbyvalue(1000)) print(nearbyvalue(900)) print(nearbyvalue(800)) print(nearbyvalue(2200))
Labels: Top 5000 python programs examples with solutions Part 7
0 Comments:
Post a Comment
Note: only a member of this blog may post a comment.
<< Home