Posts

Quizz Program using Python

Conduct Quizz Program like MCQ( Multi Choice Question ) using python... Concept: First, create three text file one for store quizz questions then, second file for store keys for question in quizz and then finally, third file for store the registered student list. Input / Output: enter your register number :101 1. What is answer of this expression, 22 % 3 is? options: A.7  B.1  C.0  D.5 2. What is the output of this expression, 3*1**3? options: A.27  B.9  C.3  D.1 3. Which of the following will run without errors ? options: A.round(45.8)  B.round(6352.898,2,5)  C.round()  D.round(7463.123,2,1) 4. What is the output of “hello”+1+2+3 ? options: A.hello6  B.hello  C.Error  D.hello123 5. Suppose list1 is [1, 3, 2], What is list1 * 2 ? options: A.[2, 6, 4]  B.[1, 3, 2, 1, 3]  C.[1, 3, 2, 1, 3, 2]  D.[1, 3,  2, 3, 2, 1] enter 1 questions answer : 1,c enter 2 questions answer : 2,c enter 3 questions answer : 3,a enter 4 questions answer : 4,b enter 5 questi

Manage Employee Details using Python

Create and Manage the employee details using python... Concept: create unique email id for each registered employee and access the data of employee's using employee id that is Add employee and View employee. eg: VigneshwaranS1998@vtech.com ( employee id ) Input / Output: 1. Add Employee  2. View Employee Enter option: 1 first name: Vigneshwaran last name: S dd-mm-yyyy: 31-12-1998 Do you want to continue press y/n: y 1. Add Employee  2. View Employee Enter option: 2 Enter your employee id: VigneshwaranS1998@vtech.com Firstname  : Vigneshwaran Lastname   : S DOB        : 31-12-1998 EmployeeID : VigneshwaranS1998@vtech.com Program: for python 3... l = 'y' f = open('emplis.txt','a') f.write('************ Employee Detail list ********************\n') lis = [] while l == 'y':          print("""1. Add Employee  2. View Employee """)     option = int(input("Enter option: "))

Swap file using python

Swap the two files lines from one to one using python...  Input: create two text files Output: Interchange the lines of two file.  (i.e.,) sample.txt file lines is stored to sample2.txt file and sample2.txt file lines is stored to sample.txt file Program: for python 3... a=open("sample.txt") x=a.read() print(x) a.close() b=open("sample2.txt") y=b.read() print(y) b.close() c=open('sample.txt','w') c.write(y) print(c) c.close() d=open('sample2.txt','w') d.write(x) print(d) d.close() --------------------------------------------------------------------------------

Addition Game using Python

Adding something numbers like games using python... Concept: It is two players game. first one player start to play game saying something number within 1 - 9, then another one player continue to say the next  number within 1 - 9 until which player is saying a number then it will reaching totally 100 then, which player to lastly saying number that player is win the game. Program: for python 3... n=0 while(n!=100):     a=int(input("a="))     if(a>0 and a<=10):         n=n+a         if(n==100):             print("a is win")         b=int(input("b="))         if(b>0 and b<=10):             n=n+b             if(n==100):                 print("b is win") -------------------------------------------------

Bubble Sort Program in Python

Sort the given set of number in order using Bubble Sort in Python... Input: How many numbers you have to sort n = 5 get input as 5 number in a set is list = [10, 50,20,15,5] Output: Sorted array is: 5 10 15 20 50  Program: for python 3... n = int(input()) lis = [] for i in range(n):     k = int(input())     lis.append(k)      for i in range(len(lis)):          for j in range(0, len(lis)-i-1):                  if lis[j] > lis[j+1]:                          lis[j], lis[j+1] = lis[j+1], lis[j]   print ("Sorted array is:") for i in range(len(lis)):          print (lis[i],end=" ") -------------------------------------------------

Factorial Program in Python

Find the factorial for given number using python... Input: Given number ( 2,3,4,5,....) Output: If your input number is 4 then, the output is 24. Program: for python 3... def fact(n):     if n == 1:         return n     else:         return n * fact(n-1) print(fact(4)) ------------------------------------------------------------------------------

Triangle Program in Python

Print the Triangle in stars( * ) using Python... Output:        *        * *       * * *      * * * *     * * * * *    * * * * * *   * * * * * * *  Program: for python 3... n = 7 for i in range(n):          for j in range(0,n):         print(end=" ")     n = n-1         for k in range(0,i+1):         print("*",end=" ")     print("\r") ------------------------------------------------------------------------------------ Right hand triangle in numbers( 0-9 ) using python... Output: 1 22 333 4444 55555 666666 7777777 88888888 999999999 Program: for python 3... n = 9 k = 1 for i in range(n):     for j in range(0,i+1):         print(k,end="")     print("\r")     k = k+1 ---------------------------------------------