Booleans Homework

Samarth Hande

Hack 1

import getpass

user = input("Username: ")
passwd = getpass.getpass("Password: ")

username_correct = user == "admin"
passwd_correct = passwd == "password"

if username_correct and passwd_correct:
    print("Login Sucsess!")
else:
    print("Sorry, try again")
Login Sucsess!

Hack 2

text = input("Enter number with decials:" )
if text.count(".") > 1:
    print("Deny user")
else:
    print("Allow user")

Hack 3

%%javascript

let justDone = false;

// Now the user presses enter
justDone = true;

// Clear the screen
if (justDone) {
    output.innerHTML = "";
    justDone = false;
}

Hack 4

let isNeg = false;

// Toggle the output from positive to negitive, or visa versa
if (isNeg) {               // currently negative
  output.innerHTML = output.innerHTML.slice(1);
  isNeg = false;
} else {                   // currently positive
  output.innerHTML = "-" + output.innerHTML;
  isNeg = true;
}