แสดงบทความที่มีป้ายกำกับ Lab 4x (Python) แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Lab 4x (Python) แสดงบทความทั้งหมด

วันจันทร์ที่ 21 กันยายน พ.ศ. 2558

Lab 4x - (Python) Summary of Integers

>>> def setup():
count = 1
n = 10
nsum = 0
while (count <= n):
nsum = nsum + count
count = count + 1
print("summation=",nsum)


>>> setup()
summation= 1
summation= 3
summation= 6
summation= 10
summation= 15
summation= 21
summation= 28
summation= 36
summation= 45
summation= 55
>>>

Lab 4x - (Python) Power of Ten

>>> def power_ten(num):
      if(num==6):
         print ("10 ^",num,"is Million")
      if(num==9):
         print ("10 ^",num,"is Billion")
      if(num==12):
         print ("10 ^",num,"is Trillion")
      if(num==15):
         print ("10 ^",num,"is Quadrillion")
      if(num==18):
         print ("10 ^",num,"is Quintillion")
      if(num==21):
         print ("10 ^",num,"is Sextillion")
      if(num==30):
         print ("10 ^",num,"is Nonillion")
      if(num==100):
         print ("10 ^",num,"is Googol")

       
>>> power_ten (9)
10 ^ 9 is Billion
>>>


Lab 4x - (Python) BMI Calculator

>>> def cal_bmi(weight,height):
   bmi = weight/((height/100)**2)
   print("Youe BMI is ",bmi)

 
>>> cal_bmi(62,173)
Youe BMI is  20.715693808680545


Lab 4x - (Python) Grade

>>> def setup():
  score = 78
  print("Your score was =",score)
  if score<101and score>=80:
    print("A")
  if score<80and score>=70:
    print("B")
  if score<70and score>=60:
    print("C")
  if score<60and score>=50:
    print("D")
  if score<50:
    print("F")

 
>>> setup()
Your score was = 78
B
>>>


วันอังคารที่ 15 กันยายน พ.ศ. 2558

Lab 4x - (Python) Mutiple Table

def setup():
    print (multi(7, 12))


def multi(n , row):
    i=0
    while (i <= row):
        result =  n * i
        print( n,"*",i,"=",result)
    i = i + 1

setup()

Lab 4x - (Python) Summary of Integers

def setup():
print (cal_sum(10))
print (cal_sum(15))


def cal_sum (i):
a = 0
x = 1
while (x<=i):
a = a+x
x = x+1
print("Sum 1 to",i,"=",a)


setup()


Lab 4x - (Python) Test

def setup():
  num = 0
  numl = 8
while (num<=numl):
print(num)
num = num + 1

setup()