Skip to content

Commit

Permalink
Django c sharp (#620)
Browse files Browse the repository at this point in the history
* test-commit-php

* Update php-quiz.md

* new questions with correct answers starting Q26

* django new questions Nr. 43-48, C# Nr. 41-45

Co-authored-by: Timo <timo@vm_work>
Co-authored-by: tik9 <laptop linux>
Co-authored-by: unknown <win10_lenovo_ti>
Co-authored-by: tik <lenovo>
  • Loading branch information
tik9 and Timo authored Oct 23, 2020
1 parent 8b8e9d0 commit 267aa7b
Show file tree
Hide file tree
Showing 2 changed files with 190 additions and 2 deletions.
36 changes: 34 additions & 2 deletions c#/c-sharp-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Attribute.GetCustomAttribute(typeof(ExampleController), typeof(SubControllerActi
- [ ] descending
- [ ] first in, first out

#### Q17. Lambda expressions are open used in tandem with which of the following?
#### Q17. Lambda expressions are often used in tandem with which of the following?

- [ ] Namespaces
- [x] LINQ
Expand Down Expand Up @@ -330,7 +330,7 @@ loginCallback(true);

- [ ] Login successful...
- [ ] Valid user!
- [x] an error, because the method signature of Login doesn't match the delegate //It will throw an error because you cant apply Inheritance to methos that way.
- [x] an error, because the method signature of Login doesn't match the delegate //It will throw an error because you cant apply Inheritance to methods that way.
- [ ] Login successful... Valid user!

#### Q39. How would you declare a sealed class named User?
Expand All @@ -344,3 +344,35 @@ loginCallback(true);
- [ ] `public delegate ResultCallback(int responseCode)`;
- [x] `public delegate void ResultCallback(int responseCode)`;
- [ ] `public void delegate ResultCallback<int responseCode>`;

#### Q41. What is the difference between non-static and static classes?
- [] non-static classes need to be initialized before use, while static classes do not
- [] non-static classes are accessible only from an interface while static classes are accessible from anywhere
- [] non-static classes need to initialize all class members at runtime, while static classes do not
- [] non-static classes do not need to be initialized while static classes do

#### Q42. Which characteristic prevents this code from compiling?
public int age="28"
- [x] type safety
- [] single inheritance
- [] dependency injection
- [] multiple inheritance

#### Q43. How would you serialize this class?
public class User {}
- [] mark the User class with the DeserializableAttribute
- [] Declare it as public serializable class User {}
- [] Mark it with the SerializableAttribute
- [] Declare it as private serializable class User{}

#### Q44. How would you write a delegate named ResultCallback with an int parameter named responseCode
- [] public delegate ResultCallback(int responseCode)
- [] public delegate void ResultCallback<(int) responseCode>;
- [] public void delegate ResultCallback<int responseCode>;
- [x] public delegate void ResultCallback(int responseCode);

#### Q45. What is the difference between a static and non-static method?
- [] non-static methods always need to have a void return type
- [] non-static methods do not have access to static member variables
- [x] static methods do not have to instantiate an instance of the class to call the method
- [] static methods always have to be public
156 changes: 156 additions & 0 deletions django/django-quiz.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,159 @@ django.getVersion()
👍 - import django
django.get_version()
- python -c django --version

Q32. You should use the http method __ to read data and __ to update or create data
- read;write
- get; post
- post; get
👍 - get; patch

Q33. When should you employ the POST method over GET for submitting data?
- when efficiency is important
- for caching data
- help your browser with debugging
👍 - data may be sensitive

Q34. When to use the Django sites framework?
👍 - if your single installation powers more than one site
- if you need to serve static as well as dynamic content
- if you want your app have a fully qualified domain name
- if you are expecting more than 10.000 users

Q35. Which infrastructure do you need:
title=models.charfield(max_length=100, validators=[validate_spelling])
- inizialized array called validators
👍 - a validators file containing a function called validate_spelling imported at the top of model
- a validators file containing a function called validate imported at the top of model
- spelling package imported at the top of model

Q36. What decorator is used to require that a view accepts only the get and head methods?
👍 - require_safe()
- require_put()
- require_post()
- require_get()

Q37. How would you define the relation between a book and an author - book has only one author.
- class Author (models.model):
book=models.foreignkey(Book,on_delete=models.cascade)
class Book(models.model):
name=models.charfield(max_length=100)

👍 - class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)

- class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author)

- class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=models.foreignkey(Author,on_delete=models.cascade)

- class Author (models.model):
name=models.charfield(max_length=100)
class Book(models.model):
author=Author.name

Q38. What is a callable that takes a value and raises an error if the value fails?
👍 - validator
- deodorizer
- mediator
- regular expression

Q39. To secure an API endpoint, making it accessible to registered users only, you can replace the rest_framework.permissions.allowAny value in the default_permissions section of your settings.py to
- rest_framework.permissions.IsAdminUser
👍 - rest_framework.permissions.IsAuthenticated
- rest_framework.permissions.IsAuthorized
- rest_framework.permissions.IsRegistered

Q40. Which command would you use to apply a migration?
- makemigration
-update_db
- applymigration
👍-migrate

Q41. Which type of class allows QuerySets and model instances to be converted to native Python data types for use in APIs?
- objectwriters
👍- serializers
- picklers
- viewsets

Q42. How should the code end?
{% if spark >= 50 %}
Lots of spark
{% elif spark == 42 %}
The answer

- {% else %}
👍- {% endif %}
- Nothing needed
- {% end %}


Q43 Which code block will create a serializer?
from rest_framework import serializers
from .models import Planet
- [x]
class PlanetSerializer(serializers.ModelSerializer):
class Meta:
model=Planet
fields=('name','position', 'mass', 'rings')


- []
from rest_framework import serializers
from .models import Planet
class PlanetSerializer():
class Meta:
fields=('name','position', 'mass', 'rings')
model=Planet

- []
from django.db import serializers
from .models import Planet
class PlanetSerializer(serializers.ModelSerializer):
fields=('name','position', 'mass', 'rings')
model=Sandwich

- []
from django.db import serializers
from .models import Planet
class PlanetSerializer(serializers.ModelSerializer):
class Meta:
fields=('name')
model=Planet

Q44 Which class allows you to automatically create a Serializer class with fields and validators that correspond to your model's fields?
- [x] ModelSerializer
- [] Model
- [] DataSerializer
- [] ModelToSerializer

Q45 Which command to access the built-in admin tool for the first time?
- [] django-admin setup
- [] django-admin runserver
- [] python manage.py createuser
- [x] python manage.py createsuperuser

Q46. Virtual environments are for managing dependencies. Which granularity works best?
- [x] you should set up a new virtualenv for each Django project
- [] They should not be used
- [] Use the same venv for all your Django work
- [] Use a new venv for each Django app

Q47. What executes various Django commands such as running a webserver or creating an app?
- [] migrate.py
- [] wsgi.py
- [x] manage.py
- [] runserver

Q48. What do Django best practice suggest should be "fat"?
- [x] models
- [] controllers
- [] programmers
- [] clients

0 comments on commit 267aa7b

Please sign in to comment.