01/11/2017
import random import tkinter as tk from tkinter import ttk import tkinter.messagebox root = tk.Tk() """ *** Memory *** """ board2 = [["0", "1", "2"], ["3", "4", "5"], ["6", "7", "8"]] a = ["X"] """ *** Functions *** """ player = tkinter.messagebox.askyesno("First thing first", "Playing against another player?") print("is there another player? ", player) def turn(pos1, board2, button, a): """ enter choice to memory and change the board and interface """ [ 1,161 more word ]
https://sslabsdot.wordpress.com/2017/11/01/tic-tac-toe-game-using-python-3-x/
Tic-Tac-Toe Game using Python 3.x
import random import tkinter as tk from tkinter import ttk import tkinter.messagebox root = tk.Tk() “”” *** Memory *** “”” board2 = [[“0”, “1& #…
22/10/2017
function largestOfFour(arr) { // You can do this! var results = []; for (var n = 0; n < arr.length; n++) { var largestNumber = arr[n][0]; for (var sb = 1; sb < arr[n].length; sb++) { if (arr[n] > largestNumber) { largestNumber = arr[n]; } } results[n] = largestNumber; } return results; } largestOfFour([, , , ]);
find the largest array
function largestOfFour(arr) { // You can do this! var results = []; for (var n = 0; n < arr.length; n++) { var largestNumber = arr[n][0]; for (var sb = 1; sb < arr[n].length; sb++) { i…
20/10/2017
import re TESTER = re.compile( r"^" r"(?!.*(\d)(-?\1){3})" r"" r"\d{3}" r"(?:-?\d{4}){3}" r"$") for _ in range(int(input().strip())): print("Valid" if TESTER.search(input().strip()) else "Invalid")
Validating Credit Card number
import re TESTER = re.compile( r”^” r”(?!.*(\d)(-?\1){3})” r”[456]” r”\d{3}” r”(?:-?\d{4}){3}” r”$”) for _ in range(in…
17/10/2017
def check_valid(email): try: username, url = email.split("@") website, extension = url.split(".") except ValueError: return False if not username.replace("-", "").replace("_", "").isalnum(): return False if not website.isalnum(): return False if len(extension) > 3: return False return True n = int(input()) emails = valid = list(filter(check_valid, emails)) print(sorted(valid))
Email validation
def check_valid(email): try: username, url = email.split(“@”) website, extension = url.split(“.”) except ValueError: return False if not username.replace(“-“, & #…
17/10/2017
s = input() vowels = 'AEIOU' kevsc = 0 stusc = 0 for i in range(len(s)): if s[i] in vowels: kevsc += (len(s)-i) else: stusc += (len(s)-i) if kevsc > stusc: print ("Kevin", kevsc) elif kevsc < stusc: print ("Stuart", stusc) else: print ("Draw")
The minion Game
s = input() vowels = ‘AEIOU’ kevsc = 0 stusc = 0 for i in range(len(s)): if s[i] in vowels: kevsc += (len(s)-i) else: stusc += (len(s)-i) if kevsc > stusc: print (“Kevin”…
17/10/2017
s = input() for x in s[:].split(): s = s.replace(x, x.capitalize()) print(s)
Captalization
s = input() for x in s[:].split(): s = s.replace(x, x.capitalize()) print(s)
17/10/2017
import string alpha = string.ascii_lowercase n = int(input()) L = [] for i in range(n): s = "-".join(alpha) L.append((s[::-1]+s).center(4*n-3, "-")) print('\n'.join(L[:0:-1]+L))
Rangoli in Python
import string alpha = string.ascii_lowercase n = int(input()) L = [] for i in range(n): s = “-“.join(alpha[i:n]) L.append((s[::-1]+s[1:]).center(4*n-3, “-“)) print(‘ …
17/10/2017
def print_formatted(number): i = 1 width = len("{0:b}".format(number)) while i
String Formatting
def print_formatted(number): i = 1 width = len(“{0:b}”.format(number)) while i
27/09/2017
import sys a = [] n = int(input().strip()) s = input().strip() k = int(input().strip()) for i in range(n): if k > 26 : k = k%26 b = True if ord(s[i]) in range(65,91): while b: if (ord(s[i]) + k) > 90: v = chr(64 + ((ord(s[i]) + k -90))) a.append(v) break else : a.append(chr(ord(s[i]) + k)) break elif ord(s[i]) in range(97,123): [ 45 more words ]
Caesar Cipher
import sys a = [] n = int(input().strip()) s = input().strip() k = int(input().strip()) for i in range(n): if k > 26 : k = k%26 b = True if ord(s[i]) in range(65,91): while b: if (ord(s[i]) + k)…
29/08/2017
import time the time module from datetime import datetime as dt datetime form datetime module as dt host_path = r"C:\Windows\System32\drivers\etc\hosts" of host file redirect = "127.0.0.1" address where you want user to be redirect when they access site website_list = ["www.facebook.com","facebook.com"] of site you want to block while True: the names of website that have to be blocked. [ 109 more words ]
https://sslabsdot.wordpress.com/2017/08/29/website-blocker-using-python/
Website Blocker using PYTHON
import time the time module from datetime import datetime as dt datetime form datetime module as dt host_path = r”C:\Windows\System32\drivers\etc\hosts” …
17/08/2017
Save the following code in .html extension using notepad++. Reaction Time { width: 200px; height: 200px; background-color: red; display: none; position: relative; } body { font-family: sans-serif; } .bold{ font-weight: bold; } Test your Reaction Click as quick as posible Your time: function makeShapeAppear(){ [ 91 more words ]
https://sslabsdot.wordpress.com/2017/08/18/check-your-reaction-time/
Check your Reaction Time :
Save the following code in .html extension using notepad++. Reaction Time { width: 200px; height: 200px; backg…
16/08/2017
Save the following in .html format Guess The Number Guess the number of fingure I'm holding up? 0 1 2 3 4 5 guess! document.getElementById("guess").onclick = function(){ var number = document.getElementById("no.").value var numberOfGuess = 1; var gotIt = false ; while(gotIt == false){ var guess = Math.random(); [ 37 more words ]
https://sslabsdot.wordpress.com/2017/08/16/web-based-game-guess-no-of-fingres/
Web Based Game: Guess No. of fingres
Save the following in .html format Guess The Number Guess …