Adsense Ad

Thursday 25 April 2019

My first code on Python3

print("Marksheet Program\n")
ask=['Student Name: ','Father Name: ','Class: ']
ans=[]
for bio in range(0,len(ask)):
    val = input(ask[bio])
    ans.append(val.title())
print("\n")   
subjects=['English ','Urdu','Science']   
marks=[]
for score in range(0,len(subjects)):
    res=int(input(subjects[score].title()+" Obtained Marks out of 100: "))
    marks.append(res)


for printing in range(0,len(ask)):
    print(ask[printing]+ans[printing])
   
error=0
errSub=''
totalMarks=0
percentage=0
for printmarks in range(0,len(subjects)):
    if marks[printmarks] >0 and marks[printmarks] <=100:
        totalMarks=totalMarks+marks[printmarks]
        print(subjects[printmarks]+" /100 = "+str(marks[printmarks]))
    else:
        error=1
        errSub=subjects[printmarks]
        print('Invalid marks '+str(marks[printmarks])+' given for the subject '+subjects[printmarks])
if error==1:
    print("Please re-enter the marks for the "+errSub.strip()+" subject")
else:
    print("Total Marks Obtained: "+str(totalMarks)+"/300")
    percentage=totalMarks/300 * 100
    print("Percentage: "+str(percentage))
    if percentage >=80 and percentage <=100:
        print("Grade: A+")
    elif percentage >=70 and percentage <=79:
        print("Grade: A")
    elif percentage >=60 and percentage <=69:
        print("Grade: B")
    elif percentage >=50 and percentage <=59:
        print("Grade: C")
    elif percentage >=40 and percentage <=49:
        print("Grade: D")
    else:
        print("Fail")


Monday 1 April 2019

Oracle SQL: Query to get Month-Year of current year's sys date and previous months

    select  
    to_char(add_months(trunc(sysdate, 'year'), level - 1), 'MON-YYYY') mon  
    from dual  
    connect by level <= to_number(to_char(sysdate, 'MM'))  
      
    MON  
    --------  
    JAN-2019  
    FEB-2019  
    MAR-2019  
    APR-2019