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

Assigning Values to Variables examle

#assignment of python
class employee:

 def setdata(self):    
    num_employee = int(input("Please enter number of emloyees:"))
    print ("you entered %s employees" %num_employee)
    employee_info = {}
    employee_data = ['emp_id ' ,'emp_age  ', 'emp name  ', 'emp dept  ']
    for i in range(0,num_employee):
      emp_id = input("emd id  :")
      employee_info[emp_id] = {}
      for entry in employee_data:
        employee_info[emp_id][entry] = str(input(entry)) 

    for (key, value) in employee_info.items() :
        print(key , " : ", value )
        
    for key in sorted(employee_info.keys()):
      print("%s: %s" % (key, employee_info[key]))  
    
def main():
    emp = employee()
    emp.setdata()

if __name__=="__main__":
    main()
    
f = open("filepath",'w') 
f.write( "\n");

# Close opend file
f.close()

Advertisements
Loading...

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