#Print the student number, name and marks through accessing structure elements.
#Defining Structure in class
class std:
no=0
name = ''
m1 = m2 = m3 =0
#assigning variable to structure class
s=std()
#UserInput
s.no=raw_input("Give Student Number: ")
s.name=raw_input("Enter the Student Name: ")
s.m1=input("Enter Student Mark1: ")
s.m2=input("Enter Student Mark2: ")
s.m3=input("Enter Student Mark3: ")
total=avg=0.0
total = (s.m1 + s.m2 + s.m3)
avg='%.2f' %(total / 3)
#Result
print "\nThe Output is.... \n",s.no,s.name,total,avg
#print a value from Structure.
class struct:
a=b=0
x=struct()
y=struct()
x.a=29
y=x
#Result
print "The Value of a %d"%y.a
#Program for User defined data type
#There is no preprocessor directive in python
D = 7
#No typedef function in python
wk = int(raw_input("Enter Weeks : "))
#Result
print "\nNumber of Days = %d"%(wk*D)
#Program to create user defined data type from structure
class struct:
name=''
sex=''
age=0
candidate = [struct() for i in range(0,2)]
for a in range(0,2):
candidate[a].name= raw_input("Name of the Employee: ")
candidate[a].sex= raw_input("Sex: ")
candidate[a].age= input("Age: ")
#Result
print "\n Name\t Sex\t Age\n"
for a in range(0,2):
print " %s\t"%(candidate[a].name)," %s\t"%(candidate[a].sex)," %d\n"%(candidate[a].age)