Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Exercise -1
- #Дан номер некоторого года (Целое положительное число). Определить цоответствуюший ему номер столетия , учитывая #, что к примеру , #началом 20 столетия был 1901 год
- year = input ("provide year to detect century: ")
- lng = len(year)
- #year = int (year)
- ChkDig = year.isdigit()
- #print (ChkDig)
- if (ChkDig) and (int(year) >= 0 or int(year) < 0):
- year = int(year)
- if (lng>=1 and lng<=5):
- if lng==2 or lng==1:
- if year >=1:
- print("century of your provided year : 1 A.C.")
- elif year==0:
- print("century of your provided year : 1 B.C.")
- if lng==3:
- cntr= int (year//100 )
- carry = int (year - (cntr * 100))
- if carry >= 1:
- print ("century of your provided year : " , cntr+1,"A.C.")
- else:
- print ("century of your provided year : " , cntr,"A.C.")
- elif lng==4:
- cntr= int(year//100 )
- carry = int(year - (cntr * 100))
- if carry >= 1:
- print("century of your provided year : ", cntr + 1,"A.C.")
- else:
- print("century of your provided year : ", cntr ,"A.C.")
- elif (int(year) < 0) or (lng>=2 and lng<=5):
- year = int(year)
- if lng == 4:
- cntr = (-year // 100 )
- carry = int(year - (cntr * 100))
- if carry == 99:
- print("century of your required year : ", cntr + 1, "B.C.")
- else:
- print("century of your required year : ", cntr, "B.C.")
- elif lng == 5:
- cntr = (-year // 100 )
- carry = int(year - (cntr * 100))
- if carry == 99:
- print("century of your required year : ", cntr + 1, "B.C.")
- else:
- print("century of your required year : ", cntr, "B.C.")
- elif lng == 3 or lng ==2:
- if year > -99:
- print ("century of your required year : 1 B.C.")
- elif year == -99:
- print ("century of your required year : 1 A.C.")
- else:
- print ("not an year at all !!!")
- #-------------------------------------------------------------------------------------
- #Exercise -2
- #Проверить истиность вусказывания : <<Среди тре данных целых чисел хотя бы одна пара взаимно противоположных>>.
- num1 = int (input ("provide num1 "))
- num2 = int (input ("provide num2 "))
- num3 = int (input ("provide num3 "))
- if (num1==-num2) or (num1==-num3) or (num2==-num3):
- print("your statement is true ")
- else:
- print ("your statement is not occur ")
- #-------------------------------------------------------------------------------------
- #Exercise -3
- #Дано трехзначное число . Проверить истиность высказывания : <<Все цифры данного числа различны>>
- num = input ("provide number 3 digit length ")
- if (num.isdigit()):
- len = len(num)
- num = int(num)
- if (len==3) :
- a = int(num//100 % 10)
- b = int(num//10 % 10)
- c = int(num % 10)
- if (a!=b and b!=c and a!=c):
- print ("you right all 3 digits are different")
- else:
- print("some of your digits are equal")
- else:
- print ("you provided number with wrong length")
- else:
- print ("you didnt provided a number at all")
- #-------------------------------------------------------------------------------------
- #Exercise -4
- #Дано четерехзначное число . Проверить истиность высказывания :<<Данное число читается одинаково слева направо и #справа налево>>
- num = input ("provide number 4 digit length ")
- lng = len(num)
- Chk = num.isdigit()
- if (Chk) and lng==4:
- num= int(num)
- a = (num //1000 %10)
- b = (num // 100 % 10)
- c = (num // 10 % 10)
- d = (num % 10)
- if a==d and b==c :
- print ("your number is POLYNDROM")
- else:
- print("your number is not POLYNDROM")
- elif (not Chk) :
- print ("It is string and not a number")
- elif lng!=4 and (Chk):
- print("you number difirent then 4 digits")
- #-------------------------------------------------------------------------------------
- #exersise 5
- #Еще такая задача:
- #The program will first compute the tax you owe based on your income.
- #User is prompted to enter income.
- #Program will compute the total amount of tax owed based on the following:
- #Income Tax
- #0 - $45,000 = 0.15 x income
- #$45,001 - $90,000 = 6750 + 0.20 x (income – 45000)
- #$90,001 - $140,000 = 15750 + 0.26 x (income – 90000)
- #$140,001 - $200,000 = 28750 + 0.29 x (income – 140000)
- #Greater than $200,000 = 46150 + 0.33 x (income – 200000)
- #Dollar amounts should be in dollars and cents (float point numbers with two decimals shown).
- salary = input("what is your salary: ")
- Chk = salary.isdigit()
- if Chk :
- salary = int(salary)
- if salary>0 and salary<=45000 :
- tax = float (0.15 * salary)
- print ("%-10s %.2f$"%("your taxes , are : " ,tax ))
- elif salary>=45001 and salary<=90000:
- tax = 6750 + float(0.2*(salary-45000))
- print("%-10s %.2f$" % ("your taxes , are : ", tax))
- elif salary>=90001 and salary<=140000:
- tax = 15750 + float(0.26*(salary-90000))
- print("%-10s %.2f$" % ("your taxes , are : ", tax))
- elif salary>=140001 and salary<=200000:
- tax = 28750 + float(0.29*(salary-140000))
- print("%-10s %.2f$" % ("your taxes , are : ", tax))
- elif salary>200000 :
- tax = 46150 + float(0.33*(salary-200000))
- print("%-10s %.2f$" % ("your taxes , are : ", tax))
- elif salary==0:
- print ("you got taxes exemption ")
- else:
- print ("not a salary at all- seems as rubbish")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement