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 | |
print(random.randint(1, 100)) | |
## can give answers such as 45, 97, 12 3, 88 etc |
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 | |
list_of_movies_to_watch = ['harry potter', 'percy jackson', 'the matrix', 'men in black'] | |
print(random.choice(list_of_movies_to_watch)) | |
## any of the following movies will printed eg 'the matrix' |
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 secrets | |
print(secrets.token_bytes(2)) | |
print(secrets.token_bytes(4)) | |
print(secrets.token_bytes(8)) | |
print(secrets.token_bytes(12)) | |
print(secrets.token_bytes(16)) | |
print(secrets.token_bytes(12)) | |
print(secrets.token_bytes(144)) | |
## returned arguments can be | |
''' |
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 secrets | |
print(secrets.token_hex(2)) | |
print(secrets.token_hex(4)) | |
print(secrets.token_hex(8)) | |
print(secrets.token_hex(12)) | |
print(secrets.token_hex(16)) | |
print(secrets.token_hex(12)) | |
print(secrets.token_hex(144)) | |
## returned the following in one random test case | |
''' |
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 secrets | |
print(secrets.token_urlsafe(2)) | |
print(secrets.token_urlsafe(4)) | |
print(secrets.token_urlsafe(8)) | |
print(secrets.token_urlsafe(12)) | |
print(secrets.token_urlsafe(16)) | |
print(secrets.token_urlsafe(12)) | |
print(secrets.token_urlsafe(144)) | |
## returned this in one random test case | |
''' |
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 secrets | |
equal_str = '9oKOSmTqT8Kn2BnpZ7qIs7JjTleGeXa119rMfxFdoDg5zeqInGT5NMWK_y0mI2U_ldbFaiSnsfDtwMSiBGvaKCvBL7wnXkW' | |
unequeal_str = '74K2Xps1O2om5ujSWxtgq449D4_RmHGSqH2HIJgM_m4YclfhxR0LHJTtnt-9obVC8gJOXLrCzVL63OuK6Qc_BcLJioNPm4Yjz' | |
print(secrets.compare_digest(equal_str, equeal_str)) ## True | |
print(secrets.compare_digest(equal_str, unequeal_str)) ## False |
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
$(document).ready(function() { | |
$('#test-input').on('keypress', function (e) { | |
if (e.which == 32) { | |
console.log('space detected, aborting space'); | |
return false | |
} | |
}) | |
}) |
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 palindrome_checker(word): | |
reversed_word = word[::-1] | |
if reversed_word == word: | |
return True | |
else: | |
return False | |
# print(palindrome_checker('racecar')) -> returns True | |
# print(palindrome_checker('Joshua')) -> returns False |
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
function hasUserMedia() { | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia | |
|| navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
return !!navigator.getUserMedia; | |
} | |
if (hasUserMedia()) { | |
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia | |
|| navigator.mozGetUserMedia || navigator.msGetUserMedia; | |
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
## FIZZBUZZ | |
def fizz_buzz_fizzbuzz(number: int): | |
if number % 3 == 0 and number % 5 == 0: | |
return 'FizzBuzz' | |
elif number % 3 == 0: | |
return 'Fizz' | |
elif number % 5 == 0: | |
return 'Buzz' | |
else: |
OlderNewer