GithubHelp home page GithubHelp logo

python-sandbox's Introduction

Overview

Neetcode

Contains Duplicates

given an integer array nums, return true if any value appears at least twice

Fizzbuzz

Description: Given some array, iterate through the array and upon chosen conditions, print fizzbuzz

Python Basics

// (divide and floor)

Divide x by y and round the answer down to the nearest integer value. Note that if one of the values is a float, you'll get back a float. 13 // 3 gives 4 -13 // 3 gives -5 9//1.81 gives 4.0

% (modulo)

Returns the remainder of the division 13 % 3 gives 1. -25.5 % 2.25 gives 1.5.

<< (left shift)

Shifts the bits of the number to the left by the number of bits specified. (Each number is represented in memory by bits or binary digits i.e. 0 and 1) 2 << 2 gives 8. 2 is represented by 10 in bits. Left shifting by 2 bits gives 1000 which represents the decimal 8.

>> (right shift)

Shifts the bits of the number to the right by the number of bits specified. 11 >> 1 gives 5. 11 is represented in bits by 1011 which when right shifted by 1 bit gives 101which is the decimal 5.

& (bit-wise AND)

Bit-wise AND of the numbers: if both bits are 1, the result is 1. Otherwise, it's 0. 5 & 3 gives 1 (0101 & 0011 gives 0001)

| (bit-wise OR)

Bitwise OR of the numbers: if both bits are 0, the result is 0. Otherwise, it's 1. 5 | 3 gives 7 (0101 | 0011 gives 0111)

^ (bit-wise XOR)

Bitwise XOR of the numbers: if both bits (1 or 0) are the same, the result is 0. Otherwise, it's 1. 5 ^ 3 gives 6 (O101 ^ 0011 gives 0110)

~ (bit-wise invert)

The bit-wise inversion of x is -(x+1) ~5 gives -6. More details at http://stackoverflow.com/a/11810203

python-sandbox's People

Contributors

wtsia avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.