From 23b0a0d48f7edc4c32c9208646b607f244699511 Mon Sep 17 00:00:00 2001 From: neymarsabin Date: Mon, 21 Aug 2017 15:58:41 +0545 Subject: [PATCH 1/7] add picture of 2016 --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index fd086db..cdd08a5 100644 --- a/readme.md +++ b/readme.md @@ -208,6 +208,10 @@ The Python community is active, vibrant, and truly helpful. Although you can say #### Popularity/Jobs +![popularity](https://static1.squarespace.com/static/51361f2fe4b0f24e710af7ae/t/56b1187d4c2f85efc5598bb1/1454446752995/?format=750w) +Source: http://blog.codeeval.com/codeevalblog/2016/2/2/most-popular-coding-languages-of-2016 + + ![popularity](https://raw.github.com/mjhea0/python-ruby/master/images/codeeval2015.jpg) For the fourth year in a row, Python is the most popular language. Also, notice how Ruby decreased in popularity: From a6261564d9a35bababf377da892783141d2dc90c Mon Sep 17 00:00:00 2001 From: neymarsabin Date: Mon, 21 Aug 2017 16:03:08 +0545 Subject: [PATCH 2/7] fix a typo --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index cdd08a5..c087eaa 100644 --- a/readme.md +++ b/readme.md @@ -209,6 +209,7 @@ The Python community is active, vibrant, and truly helpful. Although you can say #### Popularity/Jobs ![popularity](https://static1.squarespace.com/static/51361f2fe4b0f24e710af7ae/t/56b1187d4c2f85efc5598bb1/1454446752995/?format=750w) + Source: http://blog.codeeval.com/codeevalblog/2016/2/2/most-popular-coding-languages-of-2016 From 3c9bce2c51507aac5d9dbb485725dc66718c274f Mon Sep 17 00:00:00 2001 From: Moritz Reiter Date: Tue, 23 Jan 2018 18:15:46 +0100 Subject: [PATCH 3/7] Fix typo --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c087eaa..95bc710 100644 --- a/readme.md +++ b/readme.md @@ -152,7 +152,7 @@ The difference is that there is one right way of doing this given the situation. ### More differences -As you can imagine, there are many more differences that just the syntax and philosophies of the two languages. Let's quickly look at some examples. +As you can imagine, there are many more differences than just the syntax and philosophies of the two languages. Let's quickly look at some examples. #### Learning Curve From 590c3d6728920f0fde4f10d45a6a5b55ac1b2212 Mon Sep 17 00:00:00 2001 From: Gurjus Bhasin <48339289+gsbhasin123@users.noreply.github.com> Date: Sat, 15 Feb 2020 15:37:41 -0800 Subject: [PATCH 4/7] Don't undermine python even though I'm a ruby guy --- guess.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/guess.py b/guess.py index 3a28086..569d019 100644 --- a/guess.py +++ b/guess.py @@ -7,11 +7,10 @@ print('Hello! What is your name?') name = input() -print("Hi, {}. I'm thinking of a number from 1 and 20.".format(name)) +print(f"Hi, {name}. I'm thinking of a number from 1 and 20.") while guesses < 6: - - print('What is your guess. You have {} more guesses.'.format(6-guesses)) + print(f'What is your guess? You have {6 - guesses} more guesses.') guess = input() guess = int(guess) @@ -22,8 +21,8 @@ elif guess > number: print('Too high.') elif guess == number: - print('Good job, {}! You guessed my number in {} guesses!'.format(name,guesses)) + print(f'Good job, {name}! You guessed my number in {guesses} guesses!') break if guess != number: - print('Nope. The number I was thinking of was {}.'.format(number)) + print(f'Nope. The number I was thinking of was {number}.') From 76898ea4d04d46ba9a80747aca0416168e93de9d Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 1 Dec 2021 20:11:06 +0000 Subject: [PATCH 5/7] Depythonize ruby example Some other rubyists may disagree with my version, & i encourage them to fix it. However, it's definitely more rubyish than the previous version. --- guess.rb | 26 ++++++++------------------ readme.md | 23 +++++++---------------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/guess.rb b/guess.rb index 18a7c52..1c5bdf0 100644 --- a/guess.rb +++ b/guess.rb @@ -1,30 +1,20 @@ number = rand(1..20) -guesses = 0 puts 'Hello! What is your name?' -name = gets.chomp.to_s +name = gets&.chomp -puts "Hi, #{name}. I'm thinking of a number between 1 and 20." +puts "Hi, #{name}. I'm thinking of a number between 1 and 20." -while guesses < 6 +1.upto 6 do |guesses| + puts "What is your guess? You have #{7 - guesses} more guesses." + guess = gets&.chomp.to_i - puts "What is your guess? You have #{6-guesses} more guesses." - guess = gets.chomp.to_i - guesses += 1 - - unless guess == number - message = if guess > number - "Too high" - else - "Too low" - end - puts message - else + if guess == number puts "Good job, #{name}! You guessed my number in #{guesses} guesses." exit + else + puts(guess > number ? 'Too high' : 'Too low') end - end puts "Nope. The number I was thinking of was #{number}." - diff --git a/readme.md b/readme.md index 95bc710..79d2491 100644 --- a/readme.md +++ b/readme.md @@ -281,31 +281,22 @@ if guess != number: ```ruby number = rand(1..20) -guesses = 0 puts 'Hello! What is your name?' -name = gets.chomp.to_s +name = gets&.chomp puts "Hi, #{name}. I'm thinking of a number between 1 and 20." -while guesses < 6 - - puts "What is your guess? You have #{6-guesses} more guesses." - guess = gets.chomp.to_i - guesses += 1 +1.upto 6 do |guesses| + puts "What is your guess? You have #{7 - guesses} more guesses." + guess = gets&.chomp.to_i - unless guess == number - message = if guess > number - "Too high" - else - "Too low" - end - puts message - else + if guess == number puts "Good job, #{name}! You guessed my number in #{guesses} guesses." exit + else + puts(guess > number ? 'Too high' : 'Too low') end - end puts "Nope. The number I was thinking of was #{number}." From 21df6f91a6cf4fe0f946a61d162552c187c0f5d9 Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 1 Dec 2021 20:15:06 +0000 Subject: [PATCH 6/7] Sync readme python example with guess.py --- readme.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 79d2491..f281cd9 100644 --- a/readme.md +++ b/readme.md @@ -255,11 +255,10 @@ guesses = 0 print('Hello! What is your name?') name = input() -print("Hi, {}. I'm thinking of a number from 1 and 20.".format(name)) +print(f"Hi, {name}. I'm thinking of a number from 1 and 20.") while guesses < 6: - - print('What is your guess. You have {} more guesses.'.format(6-guesses)) + print(f'What is your guess? You have {6 - guesses} more guesses.') guess = input() guess = int(guess) @@ -270,11 +269,11 @@ while guesses < 6: elif guess > number: print('Too high.') elif guess == number: - print('Good job, {}! You guessed my number in {} guesses!'.format(name,guesses)) + print(f'Good job, {name}! You guessed my number in {guesses} guesses!') break if guess != number: - print('Nope. The number I was thinking of was {}.'.format(number)) + print(f'Nope. The number I was thinking of was {number}.') ``` #### Ruby From 9f106cc3468f56a90d274d520db8622f98d7ea0c Mon Sep 17 00:00:00 2001 From: tiosgz Date: Wed, 1 Dec 2021 20:16:52 +0000 Subject: [PATCH 7/7] Make scripts executable --- guess.py | 2 ++ guess.rb | 2 ++ 2 files changed, 4 insertions(+) mode change 100644 => 100755 guess.py mode change 100644 => 100755 guess.rb diff --git a/guess.py b/guess.py old mode 100644 new mode 100755 index 569d019..8fb3b11 --- a/guess.py +++ b/guess.py @@ -1,3 +1,5 @@ +#!/usr/bin/python3 + import random diff --git a/guess.rb b/guess.rb old mode 100644 new mode 100755 index 1c5bdf0..f15c2dc --- a/guess.rb +++ b/guess.rb @@ -1,3 +1,5 @@ +#!/usr/bin/env ruby + number = rand(1..20) puts 'Hello! What is your name?'