Admin Dashboard
×

Result for: Rohit


Exam Name: Python , Django , Angular Programming

Download Result (PDF)

Total Marks: 45.0

Score: 34.0

Percentage: 75.56%


Question Answers

Sr. No. Question Selected Answer Correct Answer
1 Which type of Programming does Python support? all of the mentioned all of the mentioned
2 What does the @staticmethod decorator do in a Python class? Defines a method that doesn't receive an implicit first argument Defines a method that doesn't receive an implicit first argument
3 In Django, which method is used to create database tables based on your models? manage.py makemigrations and manage.py migrate manage.py makemigrations and manage.py migrate
4 What will be the output of the following Python code? def create_multipliers(): return [lambda x: i * x for i in range(4)] functions = create_multipliers() results = [f(2) for f in functions] print(results) [6, 6, 6, 6] [6, 6, 6, 6]
5 What will be the output of the following Python code? def create_funcs(): funcs = [] for i in range(3): def f(x, i=i): return x + i funcs.append(f) return funcs funcs = create_funcs() print([f(10) for f in funcs]) [13, 13, 13] [10, 11, 12]
6 What will be the output of the following Python code? def logger(func): def wrapper(*args, **kwargs): print(f"Calling {func.__name__}") return func(*args, **kwargs) return wrapper @logger def add(x, y): return x + y result = add(add(1, 2), add(3, 4)) print(result) Calling add (3 times), then 10 Calling add (3 times), then 10
7 What will be the Output of the Following Code? class Weird: def __init__(self, x): self.x = x def __eq__(self, other): return self.x == other.x a = Weird(10) b = Weird(10) d = {a: "Hello", b: "World"} print(len(d), d[a]) 1 Hello 2 Hello
8 What will be the Output of the Following Code? def tricky(n, cache={}): if n in cache: return cache[n] if n <= 1: return 1 cache[n] = tricky(n-1) + tricky(n-2) return cache[n] print(tricky(4)) print(tricky(3)) print(tricky(2)) 5, 3, 2 5, 3, 2
9 What will be the Output Of the Following Code? def subgen(): yield 1 yield 2 return 3 def main(): result = yield from subgen() print("Returned:", result) g = main() for val in g: print(val) 1, 2 and then error 1, 2, Returned: 3
10 What will be the Output of the Following Code? class Key: def __init__(self, val): self.val = val def __eq__(self, other): return self.val == other.val k1 = Key(1) k2 = Key(1) d = {k1: 'a', k2: 'b'} print(len(d)) 1 2
11 What will be the Output of the Following Code? def dec1(func): def wrapper(*args): print("dec1") return func(*args) return wrapper def dec2(func): def wrapper(*args): print("dec2") return func(*args) return wrapper @dec1 @dec2 def hello(): print("Hello") hello() dec1, dec2, Hello dec1, dec2, Hello
12 What will be the Output of the Following Code? def sub(): yield 1 yield 2 return "Done" def main(): x = yield from sub() print("Subgen returned:", x) g = main() for i in g: print(i) 1 2 Subgen returned: Done 1 2 Subgen returned: Done
13 What will be the Output of the Following Code? ef func(a, L=[]): L.append(a) return L print(func(1)) print(func(2)) print(func(3)) [1], [1, 2], [1, 2, 3] [1], [1, 2], [1, 2, 3]
14 Which of the following operations will NOT trigger model.save() or signals (pre_save/post_save)? MyModel.objects.bulk_create([...]) MyModel.objects.bulk_create([...])
15 What will be printed? Component: @Component({ selector: 'app-test', template: '{{ value }}' }) class TestComponent implements OnInit { value = 'initial'; ngOnInit() { setTimeout(() => this.value = 'changed', 0); } } Changed Initial
16 What does providing a service in the component (instead of module) do? Creates a new service instance per component Creates a new service instance per component
17 n a Django + Angular app using REST API, what is a good reason to disable CSRF middleware? Angular uses JWT Auth and doesn’t send CSRF tokens Angular uses JWT Auth and doesn’t send CSRF tokens
18 If an Angular frontend calls a Django API and receives a CORS error, what should be done? Configure CORS_ORIGIN_ALLOW_ALL in Django Configure CORS_ORIGIN_ALLOW_ALL in Django
19 What will be the Output of the Following Code? stack = [] for i in range(3): stack.append(i) for i in range(2): stack.pop() print(stack) [0] [0]
20 What will be the Output of the Following Code? s = "((())" stack = [] for ch in s: if ch == '(': stack.append(ch) else: if stack: stack.pop() print(len(stack)) Extra '(' remaining Extra '(' remaining
21 During project setup, if ng serve fails with the error "Local workspace file ('angular.json') could not be found", what is the likely issue? The angular.json file is missing or misplaced Problems with node_modules
22 In Angular, which file is used to define the set of modules, components, and services? app.module.ts app.module.ts
23 What will be the Output of the Following Code? def f(x, l=[]): for i in range(x): l.append(i*i) return l print(f(3)) print(f(2)) [0, 1, 4] [0, 1, 4] [0, 1, 4, 0, 1]
24 In Angular (≥2+), what is the difference between NgModule.imports and NgModule.exports? imports declares dependencies the module needs, exports makes parts available to other modules imports declares dependencies the module needs, exports makes parts available to other modules
25 Which of these is a valid way to lazily load a module in Angular’s router (from Angular 8+)? { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) } { path: 'admin', loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule) }
26 Given the following models: class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): title = models.CharField(max_length=100) author = models.ForeignKey(Author, on_delete=models.CASCADE, related_name='books') Which of these queries returns all Author instances that have no books? Author.objects.filter(books__isnull=True) Author.objects.filter(books__isnull=True)
27 What happens when you call save() on a Django model instance without specifying force_insert or force_update, and the instance has a primary key that already exists in the database? It will do an UPDATE It will do an UPDATE
28 In Django REST Framework (DRF), what is the main function of SerializerMethodField? It serializes file fields only It enables custom read-only fields whose value is computed by a method
29 Which of the following is the most efficient way to handle a large number of background tasks in Django? Integrating with a task queue like Celery. Integrating with a task queue like Celery.
30 How would you implement real-time communication (e.g., chat) in a Django application? Using Django Channels for WebSockets. Using Django Channels for WebSockets.
31 What is the primary purpose of ChangeDetectionStrategy.OnPush in Angular? To improve performance by only checking for changes when input properties change or an event is explicitly triggered. To improve performance by only checking for changes when input properties change or an event is explicitly triggered.
32 How can you ensure proper communication between two unrelated Angular components without a direct parent-child relationship? Utilizing a shared service with a Subject or BehaviorSubject. Utilizing a shared service with a Subject or BehaviorSubject.
33 When integrating Django as a backend and Angular as a frontend, what is the recommended approach for handling user authentication and authorization? Implementing token-based authentication (e.g., JWT) where Django issues tokens and Angular stores and sends them. Implementing token-based authentication (e.g., JWT) where Django issues tokens and Angular stores and sends them.
34 What will be the Output of the Following Code? Python x = 10 def outer_func(): x = 5 def inner_func(): print(x) inner_func() outer_func() 5 5
35 What is the best data structure to implement a cache with FIFO eviction policy? Queue + HashMap Queue + HashMap
36 What is the purpose of csrf_token in a Django form? To prevent Cross-Site Request Forgery (CSRF) attacks by ensuring the request comes from your own site To prevent Cross-Site Request Forgery (CSRF) attacks by ensuring the request comes from your own site
37 What is the main advantage of lazy loading feature modules in Angular? It allows for loading modules on demand, which reduces the initial application load time. It allows for loading modules on demand, which reduces the initial application load time.
38 What is the main purpose of the RouterModule.forRoot() method in Angular? To register the routing service and provide the router configuration for the root application module. To register the routing service and provide the router configuration for the root application module.
39 What is the difference between constructor and ngOnInit in an Angular component? constructor is for dependency injection and simple initializations, while ngOnInit is for more complex logic that should run after the component's inputs are available. constructor is for dependency injection and simple initializations, while ngOnInit is for more complex logic that should run after the component's inputs are available.
40 What does the queryset attribute in a Django generic ListView define? The list of objects that the view will display The list of objects that the view will display
41 In the context of exception handling, what is the purpose of the finally block? It is always executed, regardless of whether an exception occurred or not. It is always executed, regardless of whether an exception occurred or not.
42 What does the pass statement do in Python? It skips the current iteration of a loop. It acts as a placeholder where code is syntactically required but no action is needed.
43 How do you pass data from a child component back up to a parent component By directly modifying the parent's properties. B) Using @Output() and an EventEmitter.
44 In the Django MVT (Model-View-Template) architecture, what is the "T"? Template Template
45 How do you pass data from a parent component to a child component? Using the @Input() decorator. Using the @Input() decorator.
  Page 1  
Admin Dashboard