Skip to content

Commit 7084af0

Browse files
committed
test
1 parent 5f49917 commit 7084af0

File tree

6 files changed

+268
-0
lines changed

6 files changed

+268
-0
lines changed

Backend/test3.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import re
2+
3+
# Read input from text file
4+
with open('question_papers/cluster_questions.txt', 'r') as file:
5+
text = file.read()
6+
7+
# Extract module numbers and questions
8+
module_questions = {}
9+
current_module = None
10+
11+
lines = text.split('\n')
12+
for line in lines:
13+
if line.startswith('Module'):
14+
current_module = re.findall(r'\d+', line)[0]
15+
module_questions[current_module] = []
16+
elif line.strip().startswith('-'):
17+
question = line.strip()[1:].strip()
18+
question = re.sub(r'(\.\s+)', '. ', question)
19+
module_questions[current_module].append(question)
20+
21+
# Save module questions to a file
22+
with open('question_papers/module_questions.txt', 'w') as file:
23+
for module, questions in module_questions.items():
24+
file.write(f"Module {module}:\n")
25+
for question in questions:
26+
file.write(f"- {question}\n")
27+
28+
print("Module questions saved to 'module_questions.txt' file.")

Backend/test4.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import re
2+
3+
# Read input from text file
4+
with open('question_papers/cluster_questions.txt', 'r') as file:
5+
text = file.read()
6+
7+
# Remove old numbering and add decimal numbering
8+
lines = text.split('\n')
9+
module_questions = {}
10+
current_module = None
11+
question_number = 1
12+
13+
for line in lines:
14+
if line.startswith('Module'):
15+
current_module = re.findall(r'\d+', line)[0]
16+
module_questions[current_module] = []
17+
question_number = 1
18+
elif line.strip().startswith('-'):
19+
question = line.strip()[1:].strip()
20+
if question.startswith('('):
21+
question = question[1:].strip()
22+
question = re.sub(r'^[IVX]+\.?\s*', str(question_number) + '. ', question)
23+
module_questions[current_module].append(question)
24+
question_number += 1
25+
26+
# Save module questions to a file
27+
with open('module_questions.txt', 'w') as file:
28+
for module, questions in module_questions.items():
29+
file.write(f"Module {module}:\n")
30+
for question in questions:
31+
file.write(f"{question}\n")
32+
33+
print("Module questions saved to 'module_questions.txt' file.")

Backend/test5.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import torch
2+
from transformers import GPT2LMHeadModel, GPT2Tokenizer
3+
4+
# Load the pre-trained model and tokenizer
5+
model_name = 'gpt2'
6+
model = GPT2LMHeadModel.from_pretrained(model_name)
7+
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
8+
9+
def generate_model_questions(input_questions, num_questions=1):
10+
# Encode input questions
11+
input_ids = tokenizer.encode(input_questions, return_tensors='pt')
12+
13+
# Generate model questions
14+
max_length = 512 # Adjust the maximum length of the generated questions
15+
temperature = 1.0 # Adjust the temperature for controlling randomness
16+
17+
model_questions = []
18+
for _ in range(num_questions):
19+
outputs = model.generate(
20+
input_ids,
21+
max_length=max_length,
22+
num_return_sequences=1,
23+
temperature=temperature,
24+
repetition_penalty=1.0,
25+
pad_token_id=tokenizer.eos_token_id,
26+
early_stopping=True
27+
)
28+
29+
# Decode the generated model question
30+
model_question = tokenizer.decode(outputs[0], skip_special_tokens=True)
31+
model_questions.append(model_question)
32+
33+
return model_questions
34+
35+
# Example usage
36+
input_questions = """1. Explain the design procedure of combinational circuit with an example
37+
2. Implement the following function using a multiplexer
38+
3. Compare TTL and CMOS logic families.
39+
4. Implement the following Boolean function with NAND gates: OR
40+
5. Implement the following function using a multiplexer (Use B as input)"""
41+
model_questions = generate_model_questions(input_questions)
42+
43+
print("Input Question:")
44+
print(input_questions)
45+
print("\nModel Questions:")
46+
for i, question in enumerate(model_questions, 1):
47+
print(f"{i}. {question}")

module_questions.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Module 1:
2+
1. (a) Convert (63.25) 10 to Hexa decimal and octal.
3+
2. (a) Perform the following number conversions:
4+
3. (a) Convert (AB2)16 to octal.
5+
4. (a) (
6+
5. (a) Perform the following:
7+
6. (a) Given the two binary numbers X = 1010100 and Y = 1000011, perform the
8+
Module 2:
9+
1. Explain the design procedure of combinational circuit with an example
10+
2. Implement the following function using a multiplexer
11+
3. Compare TTL and CMOS logic families.
12+
4. Implement the following Boolean function with NAND gates: OR
13+
5. Implement the following function using a multiplexer (Use B as input).
14+
6. Explain the operation of 2 input CMOS NOR gate and CMOS inverter in
15+
7. Explain with circuit diagram a typical 2 input TTL NAND gate.
16+
8. (a) Explain the working of a 4-bit BCD adder with block diagram (7)
17+
9. (a) Explain the working of a 4-bit magnitude comparator. (5)
18+
10. (a) Explain the working of SR latch with NAND gate with the help of logic diagram (6)
19+
11. (a) Design a combinational circuit using a ROM.The circuit accepts three bit (6)
20+
12. Explain the working of RTL and DTL circuit. Explain how fan-out of DTL gate (10)
21+
13. (a) Explain the working of Decimal adder with block diagram and explain the (5)
22+
14. (5)
23+
15. (a) Explain the working of SR latch using NOR gate with the help of logic (6)
24+
16. (a) Draw and explain the working of Basic RTL NOR gate. (5)
25+
17. (a) Design a PLA circuit to implement the functions (6)
26+
18. (a) Draw circuit of an TTL NAND gate and explain the operation. (7)
27+
Module 3:
28+
1. Design and explain a 4 bit asynchronous up-down binary counter.
29+
2. Write short notes on (1) Fan in and Fan out (ii) Propogation delay
30+
3. Derive the expressions for a 4-bit magnitude comparator and implement it
31+
4. (a) Design a decimal adder using 4-bit binary parallel adders.
32+
5. Design a 4-bit Johnson counter. How does it differ from a ring counter?
33+
6. Design a 4-bit binary ripple counter using JK flip flops.
34+
7. Design a RAM consisting of four words of four bits each. Also show the
35+
8. Design a 4 bit binary ripple counter using JK flip flops. OR
36+
9. Design a counter that has repeated sequence of six states 0,1,2,4,5,6 using JK OR (10)
37+
10. (a) Design a 2 bit synchronous up counter using .1K flipflops. (5)
38+
11. Differentiate PLA and PAL. Draw the PLA for functions: (10)
39+
12. (a) What is Carry Propagation delay? Design a 4- bit binary parallel adder (6)
40+
13. (a) Design a synchronous counter using .T flip-flops which counts the (6)
41+
14. (a) Draw the logic diagram of a four-bit binary ripple counter. Show that a (6)
42+
Module 4:
43+
1. Simplify the following Boolean function into (1) sum-of-products form
44+
2. Prove the theorems of Boolean algebra by using postulates.
45+
3. Simplify the following function using Quine McCluskey method.
46+
4. Simplify the following Boolean function into (i) sum-of-products form and
47+
5. (a) Using 10's complement, subtract 3250-72532. (2)
48+
6. (a) Simplify the followng Boolean functions using K-map (5)
49+
7. (a) What is a gray code? What are the advantages of gray code? Find the gray (3)
50+
8. Simplify the following Boolean function using the tabulation method.
51+
9. (a) Simplify the following Boolean function into (6)
52+
10. (a) Implement the following four Boolean expressions with three half adders: (6)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
Module 1:
2+
- I. (a) Convert (63.25) 10 to Hexa decimal and octal.
3+
- I. (a) Perform the following number conversions:
4+
- I. (a) Convert (AB2)16 to octal.
5+
- I. (a) (
6+
- I. (a) Perform the following:
7+
- I. (a) Given the two binary numbers X = 1010100 and Y = 1000011, perform the
8+
9+
Module 2:
10+
- IV. Explain the design procedure of combinational circuit with an example
11+
- V. Implement the following function using a multiplexer
12+
- IX. Compare TTL and CMOS logic families.
13+
- V. Implement the following Boolean function with NAND gates: OR
14+
- VI. Implement the following function using a multiplexer (Use B as input).
15+
- VIII. Explain the operation of 2 input CMOS NOR gate and CMOS inverter in
16+
- IX. Explain with circuit diagram a typical 2 input TTL NAND gate.
17+
- IV. (a) Explain the working of a 4-bit BCD adder with block diagram (7)
18+
- V. (a) Explain the working of a 4-bit magnitude comparator. (5)
19+
- VI. (a) Explain the working of SR latch with NAND gate with the help of logic diagram (6)
20+
- VIII. (a) Design a combinational circuit using a ROM.The circuit accepts three bit (6)
21+
- IX. Explain the working of RTL and DTL circuit. Explain how fan-out of DTL gate (10)
22+
- V. (a) Explain the working of Decimal adder with block diagram and explain the (5)
23+
- X. (5)
24+
- VI. (a) Explain the working of SR latch using NOR gate with the help of logic (6)
25+
- IX. (a) Draw and explain the working of Basic RTL NOR gate. (5)
26+
- VIII. (a) Design a PLA circuit to implement the functions (6)
27+
- IX. (a) Draw circuit of an TTL NAND gate and explain the operation. (7)
28+
29+
Module 3:
30+
- VII. Design and explain a 4 bit asynchronous up-down binary counter.
31+
- VIII. Write short notes on (1) Fan in and Fan out (ii) Propogation delay
32+
- IV. Derive the expressions for a 4-bit magnitude comparator and implement it
33+
- V. (a) Design a decimal adder using 4-bit binary parallel adders.
34+
- VI. Design a 4-bit Johnson counter. How does it differ from a ring counter?
35+
- VII. Design a 4-bit binary ripple counter using JK flip flops.
36+
- VIII. Design a RAM consisting of four words of four bits each. Also show the
37+
- VII. Design a 4 bit binary ripple counter using JK flip flops. OR
38+
- VII. Design a counter that has repeated sequence of six states 0,1,2,4,5,6 using JK OR (10)
39+
- VII. (a) Design a 2 bit synchronous up counter using .1K flipflops. (5)
40+
- VIII. Differentiate PLA and PAL. Draw the PLA for functions: (10)
41+
- V. (a) What is Carry Propagation delay? Design a 4- bit binary parallel adder (6)
42+
- VI. (a) Design a synchronous counter using .T flip-flops which counts the (6)
43+
- VII. (a) Draw the logic diagram of a four-bit binary ripple counter. Show that a (6)
44+
45+
Module 4:
46+
- II. Simplify the following Boolean function into (1) sum-of-products form
47+
- III. Prove the theorems of Boolean algebra by using postulates.
48+
- II. Simplify the following function using Quine McCluskey method.
49+
- IV. Simplify the following Boolean function into (i) sum-of-products form and
50+
- II. (a) Using 10's complement, subtract 3250-72532. (2)
51+
- III. (a) Simplify the followng Boolean functions using K-map (5)
52+
- II. (a) What is a gray code? What are the advantages of gray code? Find the gray (3)
53+
- III. Simplify the following Boolean function using the tabulation method.
54+
- III. (a) Simplify the following Boolean function into (6)
55+
- IV. (a) Implement the following four Boolean expressions with three half adders: (6)
56+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
Module 1:
2+
- I. (a) Convert (63.25) 10 to Hexa decimal and octal.
3+
- I. (a) Perform the following number conversions:
4+
- I. (a) Convert (AB2)16 to octal.
5+
- I. (a) (
6+
- I. (a) Perform the following:
7+
- I. (a) Given the two binary numbers X = 1010100 and Y = 1000011, perform the
8+
Module 2:
9+
- IV. Explain the design procedure of combinational circuit with an example
10+
- V. Implement the following function using a multiplexer
11+
- IX. Compare TTL and CMOS logic families.
12+
- V. Implement the following Boolean function with NAND gates: OR
13+
- VI. Implement the following function using a multiplexer (Use B as input).
14+
- VIII. Explain the operation of 2 input CMOS NOR gate and CMOS inverter in
15+
- IX. Explain with circuit diagram a typical 2 input TTL NAND gate.
16+
- IV. (a) Explain the working of a 4-bit BCD adder with block diagram (7)
17+
- V. (a) Explain the working of a 4-bit magnitude comparator. (5)
18+
- VI. (a) Explain the working of SR latch with NAND gate with the help of logic diagram (6)
19+
- VIII. (a) Design a combinational circuit using a ROM.The circuit accepts three bit (6)
20+
- IX. Explain the working of RTL and DTL circuit. Explain how fan-out of DTL gate (10)
21+
- V. (a) Explain the working of Decimal adder with block diagram and explain the (5)
22+
- X. (5)
23+
- VI. (a) Explain the working of SR latch using NOR gate with the help of logic (6)
24+
- IX. (a) Draw and explain the working of Basic RTL NOR gate. (5)
25+
- VIII. (a) Design a PLA circuit to implement the functions (6)
26+
- IX. (a) Draw circuit of an TTL NAND gate and explain the operation. (7)
27+
Module 3:
28+
- VII. Design and explain a 4 bit asynchronous up-down binary counter.
29+
- VIII. Write short notes on (1) Fan in and Fan out (ii) Propogation delay
30+
- IV. Derive the expressions for a 4-bit magnitude comparator and implement it
31+
- V. (a) Design a decimal adder using 4-bit binary parallel adders.
32+
- VI. Design a 4-bit Johnson counter. How does it differ from a ring counter?
33+
- VII. Design a 4-bit binary ripple counter using JK flip flops.
34+
- VIII. Design a RAM consisting of four words of four bits each. Also show the
35+
- VII. Design a 4 bit binary ripple counter using JK flip flops. OR
36+
- VII. Design a counter that has repeated sequence of six states 0,1,2,4,5,6 using JK OR (10)
37+
- VII. (a) Design a 2 bit synchronous up counter using .1K flipflops. (5)
38+
- VIII. Differentiate PLA and PAL. Draw the PLA for functions: (10)
39+
- V. (a) What is Carry Propagation delay? Design a 4- bit binary parallel adder (6)
40+
- VI. (a) Design a synchronous counter using .T flip-flops which counts the (6)
41+
- VII. (a) Draw the logic diagram of a four-bit binary ripple counter. Show that a (6)
42+
Module 4:
43+
- II. Simplify the following Boolean function into (1) sum-of-products form
44+
- III. Prove the theorems of Boolean algebra by using postulates.
45+
- II. Simplify the following function using Quine McCluskey method.
46+
- IV. Simplify the following Boolean function into (i) sum-of-products form and
47+
- II. (a) Using 10's complement, subtract 3250-72532. (2)
48+
- III. (a) Simplify the followng Boolean functions using K-map (5)
49+
- II. (a) What is a gray code? What are the advantages of gray code? Find the gray (3)
50+
- III. Simplify the following Boolean function using the tabulation method.
51+
- III. (a) Simplify the following Boolean function into (6)
52+
- IV. (a) Implement the following four Boolean expressions with three half adders: (6)

0 commit comments

Comments
 (0)