Sunday, October 13, 2024

Python program to Calculate Your Name Number in Numerology

Python program to Calculate Your Name Number in Numerology
#Python program to Calculate Your Name Number in Numerology

def add(n):
    s=str(n)
    
    madd=n
    while (len(s))>1:
        i=0
        madd=0
        while i<=(len(s)-1):
            madd=madd+int(s[i])
            i=i+1
        s=str(madd)
        
    return madd

n=input("Enter a Name (only Alphabets)?")
 

c=list()
num=[1,2,3,4,5,8,3,5,1,1,2,3,4,5,7,8,1,2,3,4,6,6,6,5,1,7]
t=0.0
tot=0.0
for x in range(0,26):
    c.append(0) 

for x in n:
    x=x.upper()
    if (ord(x)>=65 and ord(x)<=91):        
        c[ord(x)-65]=c[ord(x)-65]+1

for l in range(0,26):
    t=(c[l]*num[l])
    tot=tot+t
    print(chr(l+65),"-",c[l],"-",num[l],"-",t,"-",tot )
    
print()    
print()
print ("Your Name Number in Numerology is =>",add(int(tot)))

Sample Output
Enter a Name (only Alphabets)?IsaacNewton
A - 2 - 1 - 2 - 2.0
B - 0 - 2 - 0 - 2.0
C - 1 - 3 - 3 - 5.0
D - 0 - 4 - 0 - 5.0
E - 1 - 5 - 5 - 10.0
F - 0 - 8 - 0 - 10.0
G - 0 - 3 - 0 - 10.0
H - 0 - 5 - 0 - 10.0
I - 1 - 1 - 1 - 11.0
J - 0 - 1 - 0 - 11.0
K - 0 - 2 - 0 - 11.0
L - 0 - 3 - 0 - 11.0
M - 0 - 4 - 0 - 11.0
N - 2 - 5 - 10 - 21.0
O - 1 - 7 - 7 - 28.0
P - 0 - 8 - 0 - 28.0
Q - 0 - 1 - 0 - 28.0
R - 0 - 2 - 0 - 28.0
S - 1 - 3 - 3 - 31.0
T - 1 - 4 - 4 - 35.0
U - 0 - 6 - 0 - 35.0
V - 0 - 6 - 0 - 35.0
W - 1 - 6 - 6 - 41.0
X - 0 - 5 - 0 - 41.0
Y - 0 - 1 - 0 - 41.0
Z - 0 - 7 - 0 - 41.0


Your Name Number in Numerology is => 5

Thursday, October 10, 2024

Data file using Pascal Sample Program

Data file using Pascal

program studentdatafiles;

const
  fname=  'students.dat'   ;

type
   StudentRecord = Record
      s_name: String[25];
      s_add: String[30];
      s_phone: String[20];

   end;

var
   Student: StudentRecord;
   f: file of StudentRecord;
   n:char;
procedure Addrec() ;
begin
  Assign(f,fname);
  Rewrite(f);
  n:='Y'  ;
  while  (n='Y') do
  begin
        Write('Enter Your Name ?');
        Readln(Student.s_name);
        Write('Enter your Address ?');
        Readln(Student.s_add);
        Write('Enter your Phone No ?');
        Readln(Student.s_phone);

        Write(f,Student);
        Write('Do you have another record to write (Y/N)?' );
        Readln(n);
        writeln();
  end;

  Close(f);
end;
procedure Readrec() ;
begin
  Assign(f,fname);
  Reset(f);
  writeln('Name','Address','Phone');
  while not eof(f) do
   begin
      read(f,Student);
      writeln(Student.s_name,Student.s_add,Student.s_Phone);
   end;

   close(f);
end;

begin
   Addrec();
   Readrec();
   Readln;
end.

Sample Output


Data File using Pascal Program

Pascal and Python program to find the roots of a quadric equation

Pascal program to find the roots of a quadric equation.

{find the roots of a Quadric equation ax2+bx+c=0}
program Quad;

var
  a,b,c :integer;
  d:real;

function delta(a:integer;b:integer;c:integer):real ;
begin
  delta:=sqr(b) - 4*a*c;
end;


Begin
  write('Enter the value for a ?');
  readln(a);
  write('Enter the value for b ?');
  readln(b);
  write('Enter the value for c ?');
  readln(c);
  d:= delta(a,b,c) ;
  if d> 0 then
     begin
          Writeln('You have more than one Answers');
          Write('The answer are ',((-1*b)+sqrt(d))/2*a:10:2);
          Writeln('    ',((-1*b)-sqrt(d))/2*a:10:2);
     end
  else
      if d=0 then
         begin
           Writeln('You have only one Answer');
           Writeln('The answer is ',((-1*b)/2*a):10:2);

         end
      else
         Writeln('You have no Answers');

  readln;


end.

Python Program to find the roots of a quadric equation.

import math
def delta(a,b,c):
    return b*b - 4*a*c

a=int(input("Enter Value for a?"))
b=int(input("Enter Value for b?"))
c=int(input("Enter Value for c?"))

d=delta(a,b,c)
if d>0:
    print("There are two answers  - ", ((-1*b)+ math.sqrt(d))/(2*a)," - ",((-1*b)- math.sqrt(d))/(2*a))
    
elif(d==0):
    print("There is only one answer -", (-1*b)/(2*a))

else:
    print("There is no answer")

Sample output


Pascal Program to find the roots of a quadric equation


Pascal - Quadric equation solution

Saturday, April 22, 2023

Multiple selections flowchart and Pascal Program

ICT Past Paper Questions and Answers

Question:

The following flow chart is drawn to calculate average marks (avg) and display the grades when marks (M1, M2, M3) of three subjects are given as input. The grades are decided according to the following table.

Average marks (avg) Grade
Greater than or equal to 80A
Less than 80 and greater than or equal to 65B
Less than 65 and greater than or equal to 50C
OtherwiseNo Grade


Multiple if in Pascal with flowchart

  • Fill the blank indicated by ? according to the given scenario.
  • Convert the flow chart to Pascal Program.


Answer:
1:


Multiple if flowchart and Pascal answer

2:
program Multipleif;
var
m1,m2,m3:integer;
avg:real;
begin
  writeln ('Enter three Marks');
  readln(m1);
  readln(m2);
  readln(m3);
  avg:=(m2+m3+m3)/3;
  if (avg>=80) then
  writeln('A')
  else
  if(avg>=65) then
  writeln('B')
  else
  if (avg>=50) then
  writeln('C')
  else
  writeln('No Grade')
end.

  

Tuesday, July 5, 2022

Exercises to Python GUI Programming

Tkinter - GUI Programming Python

Question 1


Write a Python GUI Program to find the Area of a Rectancle with the following features. Able to enter width and height of a rectangle by the users.

  • Proper Prompted Messages to user for the above input.
  • Button to calculate and display the area of the rectangle for the above input.
  • Font should be Helvetica and size 15

Answer - Sample Python GUI Program

from tkinter import *
from tkinter.font import *

def myclick():
    A=int(W.get())*int(H.get())
    label3.configure(text="Area of the Rectangle :" +str(A))

root = Tk(className='Python Examples - Find Area of a Rectangle')
myfont=Font(family='Helvetica', size=15, weight='bold' )

label1 =Label(text="Enter the Width of a Rectangle", width=40,font=myfont, fg='Red')
label2 = Label(text="Enter the Height of a Rectangle", width=40, font=myfont, fg='Red')
label3 = Label(text=" ", width=40, font=myfont, fg='Green')

W=Entry(font=myfont, width=4)
H=Entry(font=myfont, width=4)

button = Button(text = 'Click me', font=myfont,command = myclick)

label1.grid(row=0, column=0)
W.grid(row=0, column=1)
label2.grid(row=1, column=0)
H.grid(row=1, column=1)
button.grid(row=2, column=0,columnspan=2)
label3.grid(row=5,column=0)

root.geometry("600x500")

mainloop()

Sample Output Screen


Python GUI with Tkinter

Wednesday, February 23, 2022

RDBMS Past Paper Questions and Answers

Relational Database Management System Questions and Answer

Question 1
i) Convert the following ER diagram to table structure in a relational database. The attribute capacity may have values such as captain, vice captain, member etc.

RDBMS Past Paper Questions and Answers

Based on the table Structures obtained above answer the below questions.

ii) Write an SQL statement to get a list of sports that do not have captains.
iii) Write an SQL statement to obtain a list of students (StudentID and Name) who participate in any sport as a captain.


Answer

i)
Student(StudentID, Name)
Sport(SportID, Name)
StudentSport(StudentID, SportID, Year, Capacity)

ii)
Select distinct SportID from StudentSport where capacity <> "captain"

iii) Select Student.ID, Student.Name from Student, StudentSport where Student.StudentID=StudentSport.StudentID and StudentSport.Capacity="captain"


Question 2
The candidates who have been selected for university entrance should register for the given academic year with the university given to them. Candidate who do not register before the Last date announced by each university will lose their university entrance. Once a candidate registers with given university , the candidate becomes a registered student of that university. Registered students can apply for financial support. A student can get many financial support. These financial supports could be either full or partial. All registered students will receive a laptop. However, its ownership cannot be transferred to another student. The user requirements of the above system are listed below. A user shall be able to obtain.
i) a list of students registered for a given academic year with a given university.
ii) information (such as model, serial number, warranty period) about the laptops given to each student.
iii) list of students who applied for financial support.

Draw an entity Relationship(ER) diagram required to design a database to represent the above system description and to satisfy the user requirements. State all your assumptions clearly.

Answer

RDBMS ERD QUESTIONS ANSWERS



Tuesday, February 22, 2022

Combinational circuits Design Questions and Answers

ICT Questions and Answers

Question 1
A digital circuit takes four digits as an input, and produce 'X' as its output. If the decimal value represented by the four binary digit is a prime number. If it is prime output is 1 otherwise 0. Assume that all four binary digit represent positive decimal values.

i) Draw a truth table for the above problem.
ii) Write the Boolean expression in the sum of product form.
iii) Design a logic circuit for the Boolean expression, which is obtained above.
iv) Simplify the expression using Boolean algebra/ Karnaugh map.

Answer
i) Truth Table

ABCDX
00000
00010
00101
00111
01000
01011
01100
01111
10000
10010
10100
10111
11000
11011
11100
11110


ii) X= A'B'CD' + A'B'CD + A'BC'D + A'BCD + AB'CD + ABC'D

iii)
Combinational Circuit to detect prime numbers


iv)
Combinational Circuit Questions and Answers



Question 2
Consider the logic circuit shown here to answer the below questions.

Combinational Circuit Design ICT A/L

i) Write and simplify the Boolean expression for the above circuit using Boolean algebra . Show all the workings and algebraic rules used for the simplification.

ii) Construct the logic circuit using combination of only AND, OR and NOT gates for the simplified Boolean expression obtained above.

Answer
i)
ABC + A'BC + ABC'
BC(A+A') + ABC'
BC + ABC'
B(C+AC')
B(A+C)

ii)

Combinational Past Paper ICT Answer