Skip to content

Instantly share code, notes, and snippets.

View Gregcake's full-sized avatar
💭
Hacking into the mainframe

Greg Tan Gregcake

💭
Hacking into the mainframe
  • TradeGecko
  • Singapore
View GitHub Profile
@Gregcake
Gregcake / python.md
Last active June 26, 2019 13:57
Baisc Python

What is the output of the following block of code?

i = 0
while i < 3: 
    print i 
    i += 1
else: 
    print 0
  • 0 1 2 3 0

What does SQL stand for?

Is SQL a relational or non-relational database? Explain what that means

What is a Primary Key?

What is the difference between the Primary Key and Unique Key? Explain it in the context of the following table where ID is the Primary Key and EMAIL is the Foreign Key:

Table Name: EMAILS

|ID (PK)|NAME|AGE|EMAIL (UK)|

{:geckoship_zone=>{:name=>"CA - Zone 56", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Yukon Territory", :code=>nil, :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"33.76", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"35.5", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"37.23", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"39.24", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"39.81", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"41.68", :zone_id=>nil}, {:min_weight=>"6.1", :max_weight=>"7", :weight_unit=>"lb", :name=>"UPS Standar
{:geckoship_zone=>{:name=>"CA - Zone 55", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Northwest Territories", :code=>"NT", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"33.37", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"35.09", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"36.79", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"38.78", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"39.35", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"41.19", :zone_id=>nil}, {:min_weight=>"6.1", :max_weight=>"7", :weight_unit=>"lb", :name=>"UPS
{:geckoship_zone=>{:name=>"CA - Zone 54", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Nunavut", :code=>"NU", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"32.84", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"34.54", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"36.21", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"38.17", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"38.74", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"40.54", :zone_id=>nil}, {:min_weight=>"6.1", :max_weight=>"7", :weight_unit=>"lb", :name=>"UPS Standard", :p
{:geckoship_zone=>{:name=>"CA - Zone 53", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Alberta", :code=>"AB", :country_id=>nil, :id=>nil}, {:name=>"British Columbia", :code=>"BC", :country_id=>nil, :id=>nil}, {:name=>"New Brunswick", :code=>"NB", :country_id=>nil, :id=>nil}, {:name=>"Prince Edward Island", :code=>"PE", :country_id=>nil, :id=>nil}, {:name=>"Nova Scotia", :code=>"NS", :country_id=>nil, :id=>nil}, {:name=>"Newfoundland and Labrador", :code=>"NL", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"21.57", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"23.33", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"24.13", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Sta
{:geckoship_zone=>{:name=>"CA - Zone 52", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Saskatchewan", :code=>"SK", :country_id=>nil, :id=>nil}, {:name=>"Quebec", :code=>"QC", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"21.3", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"23.03", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"23.75", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"25.44", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"26.98", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"28.35", :zone_id=>nil}, {:min_weight=>"6.1",
{:geckoship_zone=>{:name=>"CA - Zone 51", :enabled=>true, :countries=>[{:name=>"Canada", :code=>"CA", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Manitoba", :code=>"MB", :country_id=>nil, :id=>nil}, {:name=>"Ontario", :code=>"ON", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"20.98", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"22.69", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"23.4", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"25.06", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"26.58", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Standard", :price=>"27.93", :zone_id=>nil}, {:min_weight=>"6.1", :m
{:geckoship_zone=>{:name=>"US - Zone 46", :enabled=>true, :countries=>[{:name=>"United States", :code=>"US", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"Alaska", :code=>"AK", :country_id=>nil, :id=>nil}, {:name=>"Hawaii", :code=>"HI", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"39.84", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"43.23", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"46.04", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"49.93", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"53.12", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"55.16", :zone_id=>nil}, {:min_weight=>"6.1", :max_weig
{:geckoship_zone=>{:name=>"US - Zone 7", :enabled=>true, :countries=>[{:name=>"United States", :code=>"US", :zone_id=>nil, :id=>nil, :provinces=>[{:name=>"California", :code=>"CA", :country_id=>nil, :id=>nil}, {:name=>"Oregon", :code=>"OR", :country_id=>nil, :id=>nil}]}], :price_based_rates=>[], :weight_based_rates=>[{:min_weight=>"0.1", :max_weight=>"1", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"9.8", :zone_id=>nil}, {:min_weight=>"1.1", :max_weight=>"2", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"11.24", :zone_id=>nil}, {:min_weight=>"2.1", :max_weight=>"3", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"11.98", :zone_id=>nil}, {:min_weight=>"3.1", :max_weight=>"4", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"12.87", :zone_id=>nil}, {:min_weight=>"4.1", :max_weight=>"5", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"13.46", :zone_id=>nil}, {:min_weight=>"5.1", :max_weight=>"6", :weight_unit=>"lb", :name=>"UPS Ground", :price=>"13.81", :zone_id=>nil}, {:min_weight=>"6.1", :max_wei