class Students:
def __init__(self,name,ID,age,weight,height):
self.name = name
self.ID = ID
self.age = age
self.weight = weight
self.height = height
def get_age(self):
return self.age
def setup():
a = Student("Frame", 173, 58, 32080, 20)
b = Student("Bank", 168, 60, 20071, 19)
c = Student("Pee", 166, 54, 20054, 20)
d = Student("Fern", 165, 53, 20097, 19)
nukrean = [a, b, c, d]
average(nukrean)
def average(nukrean):
i = 0
count = 0
sum = 0
a = 0
while(i < len(nukrean)):
sum = sum + nukrean[i].get_age()
count = count + 1
a = sum/count
i = i + 1
print("Average = ",a)
setup()
วันพฤหัสบดีที่ 18 สิงหาคม พ.ศ. 2559
BMI with command line argument.
import sys
def setup():
w = int (sys.argv[1])
h = float (sys.argv[2])
BMI = w/(h*h)
print("BMI =","%.3f"%BMI)
setup()
def setup():
w = int (sys.argv[1])
h = float (sys.argv[2])
BMI = w/(h*h)
print("BMI =","%.3f"%BMI)
setup()
Prime number with Command line argument.
import sys
def setup():
print(count_prime(int (sys.argv[1])))
def count_prime(n):
x = 2
count = 0
while(x <= n):
if(prime(x)):
count += 1
x += 1
return count
def prime(p):
x = 2
if (p == 1):
return False
while(x < p):
if(p%x == 0):
return False
x += 1
return True
setup()
def setup():
print(count_prime(int (sys.argv[1])))
def count_prime(n):
x = 2
count = 0
while(x <= n):
if(prime(x)):
count += 1
x += 1
return count
def prime(p):
x = 2
if (p == 1):
return False
while(x < p):
if(p%x == 0):
return False
x += 1
return True
setup()
Multiple table with Command line argument.
import sys
def setup():
N = 1
r = 13
x = int (sys.argv[1])
while(N < r):
p = x*N
print(x," x ",N," = ", p)
N += 1
setup()
def setup():
N = 1
r = 13
x = int (sys.argv[1])
while(N < r):
p = x*N
print(x," x ",N," = ", p)
N += 1
setup()
วันอังคารที่ 16 สิงหาคม พ.ศ. 2559
Class Object Method of Python.
def setup():
a = Student("Frame", 173, 58, 32080, 20)
b = Student("Bank", 168, 60, 20071, 19)
c = Student("Pee", 166, 54, 20054, 20)
d = Student("Fern", 165, 53, 20097, 19)
a.display()
print()
b.display()
print()
c.display()
print()
d.display()
print()
class Student:
def __init__(self,name,height,weight,ID,age):
self.name = name
self.height = height
self.weight = weight
self.ID = ID
self.age = age
def display(self):
print("Name", self.name)
print("Height", self.height)
print("Weight", self.weight)
print("ID", self.ID)
print("Age", self.age)
setup()
a = Student("Frame", 173, 58, 32080, 20)
b = Student("Bank", 168, 60, 20071, 19)
c = Student("Pee", 166, 54, 20054, 20)
d = Student("Fern", 165, 53, 20097, 19)
a.display()
print()
b.display()
print()
c.display()
print()
d.display()
print()
class Student:
def __init__(self,name,height,weight,ID,age):
self.name = name
self.height = height
self.weight = weight
self.ID = ID
self.age = age
def display(self):
print("Name", self.name)
print("Height", self.height)
print("Weight", self.weight)
print("ID", self.ID)
print("Age", self.age)
setup()
Built-in data structures of Python.
def setup():
array = [15, 97, 64, 28, 45, 34, -31, -14]
average(array)
def average(array):
i = 0
n = 0
sum = 0
average = 0
while(i < len(array)):
sum += array[i]
i += 1
n += 1
average = sum/n
print(average)
setup()
array = [15, 97, 64, 28, 45, 34, -31, -14]
average(array)
def average(array):
i = 0
n = 0
sum = 0
average = 0
while(i < len(array)):
sum += array[i]
i += 1
n += 1
average = sum/n
print(average)
setup()
Function Condition and Loop of Python.
def setup():
print(count_prime(10))
def count_prime(n):
x = 2
count = 0
while(x <= n):
if(prime(x)):
count += 1
x += 1
return count
def prime(p):
x = 2
if (p == 1):
return False
while(x < p):
if(p%x == 0):
return False
x += 1
return True
setup()
print(count_prime(10))
def count_prime(n):
x = 2
count = 0
while(x <= n):
if(prime(x)):
count += 1
x += 1
return count
def prime(p):
x = 2
if (p == 1):
return False
while(x < p):
if(p%x == 0):
return False
x += 1
return True
setup()
Variable of Python.
def setup():
N = 1
r = 13
x = 8
while(N < r):
p = x*N
print(x," x ",N," = ", p)
N += 1
setup()
N = 1
r = 13
x = 8
while(N < r):
p = x*N
print(x," x ",N," = ", p)
N += 1
setup()
วันศุกร์ที่ 12 สิงหาคม พ.ศ. 2559
สมัครสมาชิก:
บทความ (Atom)
Link Video Presentation Resort Managemant System Project.
Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน ทองมณี 5801012620011 ลำดับภาพ: สุพิชชา ศรีศิริ...
-
- 1NF หรือ Fisrt Normal Form มีเงื่อนไขอยู่ว่า ต้องไม่มีคอลลัมน์ใดในตารางที่มีค่ามากกว่า 1 ค่า หรือที่เรียกว่า Atomic ซึ่งหมายถึง ข้อมูลที่...
-
https://docs.google.com/spreadsheets/d/10Y6o-h8dAAKf7MHTtGvQDBJuzGkAx_X0WYVgj2nB8v0/edit?usp=sharing จากภาพจะเห็นว่า - เก...