This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input("enter n: ")) | |
number = [] | |
number.append(1) | |
number.append(1) | |
print(number[0]) | |
print(number[1]) | |
for i in range(2, n): | |
number.append(number[i-1] + number[i-2]) | |
print(number[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def get_char(): | |
return random.choice(characters) | |
def print_password(password): | |
print("auto-generated password is:") | |
print(password) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {AbstractControl, FormArray, FormControl, FormGroup, ValidationErrors} from '@angular/forms'; | |
import {Injectable} from '@angular/core'; | |
import {debounceTime, distinctUntilChanged} from 'rxjs/operators'; | |
export declare interface ServerError { | |
[key: string]: []; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- first name --> | |
<mat-form-field appearance="outline"> | |
<mat-label> First Name</mat-label> | |
<input matInput type="text" formControlName="first_name"> | |
<mat-error *ngIf="signUpForm.get('first_name').errors.required"> | |
This field is required | |
</mat-error> | |
<mat-error *ngIf="signUpForm.get('first_name').errors.minlength"> | |
Min length is {{signUpForm.get('first_name').errors.minlength.requiredLength}} | |
</mat-error> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const errorObject = { | |
first_name: 'This field is required', | |
last_name: 'This field is required', | |
email: 'This field is required', | |
password: 'This field is required', | |
re_password: 'This field is required', | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.signUpForm = this.fb.group({ | |
first_name: ['', [ | |
Validators.required, | |
Validators.maxLength(100) | |
]], | |
last_name: ['', [ | |
Validators.required, | |
Validators.maxLength(100) | |
]], | |
email: ['', [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUTH_PASSWORD_VALIDATORS = [ | |
{ | |
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from django.core.exceptions import ValidationError | |
from django.utils.translation import ugettext as _ | |
class NumberValidator(object): | |
@staticmethod | |
def validate(password, user=None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AUTH_PASSWORD_VALIDATORS = [ | |
{ | |
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', | |
}, | |
{ | |
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property | |
def total_price(self) -> Decimal: | |
""" | |
Total price is sum of all topping prices. | |
""" | |
price = Decimal(0) | |
for topping in self.toppings.all(): | |
price += topping.price | |
return price |
OlderNewer