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
from colorama import init, Fore, Back, Style | |
#اذا كنت تريد تشغيل الخطوط من ويندوز فعل هذه الدالة | |
init() | |
#الألوان الخطوط الموجودة | |
FORES = [ Fore.BLACK, Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE ] | |
# ألوان الخلفيات الموجودة | |
BACKS = [ Back.BLACK, Back.RED, Back.GREEN, Back.YELLOW, Back.BLUE, Back.MAGENTA, Back.CYAN, Back.WHITE ] | |
# شدة الألوان او الأضاءة | |
BRIGHTNESS = [ Style.DIM, Style.NORMAL, Style.BRIGHT ] |
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
def oct_to_hex(oct): | |
# write your code here | |
oct_list = [int(number) for number in str(oct)] | |
number_pos = len(oct_list) - 1 | |
decimal_list = [] | |
for number in oct_list: | |
decimal_number = number | |
for _ in range(number_pos): | |
decimal_number *= 8 | |
number_pos -= 1 |
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 | |
class EmailChecker: | |
def __init__(self,email:str): | |
self.email = email | |
self.id = None | |
self.provider= None | |
self.extention =None | |
self.is_valid() | |
def is_valid(self): |
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 time | |
def alarm_me(minutes: int, message:str) -> str: | |
alarm_time = time.time() + minutes * 60 | |
while True: | |
if time.time() > alarm_time: | |
break | |
print(message) |
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
def in_range(number:int, range_from:int, range_to:int) -> bool: | |
return number in list(range(range_from,range_to+1)) | |
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
def check_type(current_type:object): | |
""" | |
This Decorator will check the datatype of the | |
target function to validate the datatype arguments. | |
""" | |
def get_func(func): | |
def wrapper(*args,**kwargs): | |
check_values = [] | |
bad_values = [] | |
if args: |
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
def calc_execution(func): | |
def wrapper(*args,**kwargs): | |
""" | |
This wrapper will use time module to check | |
the diffrence between the time when the excution start | |
and when it's end. | |
""" | |
import time | |
start = time.time() | |
value = func(*args,**kwargs) |
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
glossary = { | |
"fruits": ["Apple", "Orange", "Banana"], | |
"vegetables": ["Cucumber", "Lemon", "Tomato"], | |
"sweets": ["Mars", "Kitkat", "Galaxy"] | |
} | |
# This about invers dictionary values from list to become a keys and their keys became a values that refer to them | |
def invert_dict(d): |
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 { memo, useState } from 'react'; | |
export default function MyApp() { | |
const [name, setName] = useState(''); | |
const [address, setAddress] = useState(''); | |
return ( | |
<> | |
<label> | |
Name{': '} | |
<input value={name} onChange={e => setName(e.target.value)} /> |
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 React, { useState, memo, useMemo, useCallback } from "react"; | |
function Box({ color, onClick }) { | |
console.log(`Box color : ${color.color}`); | |
return ( | |
<div | |
style={{ | |
margin: 10, | |
width: 75, | |
height: 75, |
OlderNewer