Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Execute Python-3 Online

print ("Welcome to Salesure Tax Payroll Calculator")
while True:
    name=input('Please enter employee name: ')
    salary=float(input("Please enter gross fortnightly payment for "+name+": "))
    annual=salary*52.143 / 2
    if annual>=0 and annual<=15000:
        withold=(salary/100)*5
        payable=salary-withold
    elif annual>=15001 and annual<=40000:
        withold=(salary/100)*15
        payable=salary-withold
    elif annual>=40001 and annual<=90000:
        withold=(salary/100)*28
        payable=salary-withold
    elif annual>=90001 and annual<=150000:
        withold=(salary/100)*21
        payable=salary-withold
    elif annual>150000:
        withold=(salary/100)*13
        payable=salary-withold
    withold=round(withold,2)
    payable=round(payable,2)
    print("Amount of tax to withhold: $",withold)
    print("Salary payable to : $",payable)
    c=input("Do you want to calculate pay for another employee? (y/n): ")
    if c=='n':
        break

3344

# Hello World program in Python
    
c_atfogo = 5
a_szöggel_szembeni_befogo = 3
b_szög melletti_befogo = 4
gamma_szog = 90

def alfa_szog(a, b, c, sz,):
    sin_a = a/c
    """Milyen műveletek szükségesek még, hogy megkapjam az alfa szöget?"""
    return alfaszog

Rajesh

import bs4

Execute Python-3 Online

# Python Tutorial for Beginners 5: Dictionaries - Working with Key-Value Pairs

student = {'name':'John','age':25,'courses':['Math','CompSci']}

print(student)
print(student['name'])
print(student['age'])
print(student['courses'])

# print(student['phone']) # error, does not exist

# get method (cleaner)
print(student.get('name'))
print(student.get('phone'))
print(student.get('phone','Not Found'))

student['phone']='555-5555'
print(student.get('phone','Not Found'))

student['name']='Jane'
print(student)

student.update({'name':'Jim','age':26, 'phone':'222-2222'})
print(student)

# del(student['age'])
# print(student)

age = student.pop('age')
print(student)
print(age)

# Loop through keys/values of our dictionary
# First, how many keys in the dict?
print(len(student))
print(student.keys())
print(student.values())
print(student.items())



# Comparisons:
# Equal:            ==
# Not Equal:        !=
# Greater Than:     >
# Less Than:        <
# Greater or Equal: >=
# Less or Equal:    <=
# Object Identity:  is


# False Values:
    # False
    # None
    # Zero of any numeric type
    # Any empty sequence. For example, '', (), [].
    # Any empty mapping. For example, {}.

condition = False

if condition:
    print('Evaluated to True')
else:
    print('Evaluated to False')
































NGU Trapezoid

from datetime import timedelta


class Trapezoid:
    def __init__(self, lv_start, ratio, s_lv):
        self.lv_start = lv_start
        self.ratio = ratio
        self.s_lv = timedelta(seconds=s_lv)

    @property
    def lv_end(self):
        b_e, lv, d = self.bonus() * self.ratio, self.lv_start, 1
        while self.bonus(lv + d) < b_e:
            d <<= 2
        while d > 1:
            d >>= 2
            if self.bonus(lv + d) < b_e:
                lv += d
        return lv + 1

    @property
    def total_lv(self):
        lv_s, lv_e = self.lv_start, self.lv_end
        return (lv_s + lv_e) * (lv_e - lv_s + 1) // 2

    @property
    def total_time(self):
        return self.s_lv * self.total_lv

    def show(self):
        print(f'lv_end = {self.lv_end}')
        print(f'total_lv = {self.total_lv}')
        print(f'total_time = {str(self.total_time)}')


class AT(Trapezoid):
    def bonus(self, lv=None, additive=False):
        lv = lv or self.lv_start
        return int(not additive) + round(lv ** 0.4 / 10, 4)


class NGU(Trapezoid):
    def bonus(self, lv=None, additive=False):
        lv = lv or self.lv_start
        return int(not additive) + 0.001 * lv


at = AT(lv_start=280, ratio=800000/794590, s_lv=10/280)
at.show()

Execute Python-3 Online

# Hello World program in Python
    
print ("Hello World!");

process

# Hello World program in Python
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq

my_url = "https://www.appliancesconnection.com/ranges.html"
uClient= uReq(my_url);
page_html = uClient.read()

pandas Foundations-Chapter 2

# =============================================================================
# Visual exploratory data analysis
# =============================================================================

''' pandas line plots '''

# given a dataframe "df" of stock price
# df.head()
'''
  Month        AAPL        GOOG         IBM
0   Jan  117.160004  534.522445  153.309998
1   Feb  128.460007  558.402511  161.940002
2   Mar  124.430000  548.002468  160.500000
3   Apr  125.150002  537.340027  171.289993
4   May  130.279999  532.109985  169.649994
'''

# Create a list of y-axis column names: y_columns
y_columns = ["AAPL", "IBM"]

# Generate a line plot
df.plot(x="Month", y=y_columns)

# Display the plot
plt.show()

''' pandas scatter plots '''

# Generate a scatter plot
df.plot(kind="scatter", x='hp', y='mpg', s=sizes)

''' pandas box plots '''

# Make a list of the column names to be plotted: cols
cols = ["weight", "mpg"]

# Generate the box plots
# subplots:將 x 軸的項目畫在不同圖表上
df[cols].plot(kind="box", subplots=True)

''' pandas hist, pdf and cdf '''

# This formats the plots such that they appear on separate rows
fig, axes = plt.subplots(nrows=2, ncols=1)

# Plot the PDF
df["fraction"].plot(ax=axes[0], kind='hist', bins=30, normed=True, range=(0,.3))
plt.show()

# Plot the CDF
df["fraction"].plot(ax=axes[1], kind='hist', bins=30, normed=True, cumulative=True, range=(0,.3))
plt.show()

# =============================================================================
# Statistical exploratory data analysis
# =============================================================================

''' 圖示平均值 '''

# Construct the mean percentage per year: mean
mean = df.mean(axis="columns")

# Plot the average percentage per year
mean.plot()

# Display the plot
plt.show()

''' box plot '''

# Print summary statistics of the fare column with .describe()
# mean, std, min, 25%, median, 75%, max
print(df["fare"].describe())

# Generate a box plot of the fare column
df["fare"].plot(kind="box")

# Show the plot
plt.show()

''' Quantiles '''

# Print the 5th and 95th percentiles
print(df.quantile([0.05,0.95]))

# =============================================================================
# Separating populations
# =============================================================================

''' Filtering and counting '''

# extract the rows that contain 'Asia'
print(df[df["origin"] == "Asia"].count())
'''
mpg       79
...
name      79
'''

''' Separate and plot '''

# Display the box plots on 3 separate rows and 1 column
fig, axes = plt.subplots(nrows=3, ncols=1)

# Generate a box plot of the fare prices for the First, second and third passenger class
titanic.loc[titanic['pclass'] == 1].plot(ax=axes[0], y='fare', kind='box')
titanic.loc[titanic["pclass"] == 2].plot(ax=axes[1], y='fare', kind='box')
titanic.loc[titanic["pclass"] == 3].plot(ax=axes[2], y='fare', kind='box')

# Display the plot
plt.show()

test_AMY_TRELOAR.py

# Hello World program in Python
def check_speed(speed):
    if speed < 60:
        return ("OK")
    else:
        print ("over")
        km_over = speed - 60
        if km_over % 5 == 0:
            dem = speed/5
            return (f"{round(dem)} demerit points")
            
        else:
            dem = speed/5
            return (f" approx {round(dem)} demerit points")
        return km_over
    
print(check_speed(70))

print (10/5)
print (10%5)
print (5%10)

example

#!/usr/bin/python3

class Employee:
   'Common base class for all employees'
   empCount = 0

   def __init__(self, name, salary):
      self.name = name
      self.salary = salary
      Employee.empCount += 1
   
   def displayCount(self):
     print ("Total Employee %d" % Employee.empCount)

   def displayEmployee(self):
      print ("Name : ", self.name,  ", Salary: ", self.salary)


#This would create first object of Employee class"
emp1 = Employee("Zara", 2000)
#This would create second object of Employee class"
emp2 = Employee("Manni", 5000)
emp3 = emp2
emp3.salary = 19999199

emp1.displayEmployee()
emp2.displayEmployee()
emp3.displayEmployee()
print ("Total Employee %d" % Employee.empCount)

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.