Neverending Python Challenges Game!

+11 Aubree Keegan · August 27, 2014
I think that Bucky's challenges are really fun and they are helping me learn too, so here is an idea I just came up with.

We will start with a programming challenge. As soon as a user completes that challenge, they will post the answer and also a challenge of their own! This way, we will always have a new problem to work on.

Here is my first one:

Create a Python program that will complete this song:

10 Green Bottles hanging on the wall
10 Green Bottles hanging on the wall
And if one Green Bottle should accidentally fall
There'll be 9 Green Bottles hanging on the wall

9 Green Bottles hanging on the wall
9 Green Bottles hanging on the wall
And if one Green Bottle should accidentally fall
There'll be 8 Green Bottles hanging on the wall

...


Whoever answer first can post the next challenge!  :happy:

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
0 Svante Nilsson · September 27, 2014

def Fibo(number):

    a = 0
    b = 1
    c = 0
    while number > c:
        c = a + b
        a = b
        b = c
    if number == c or number == 0:
        return True
    else:
        return False

print(Fibo(int(input("Enter your number:"))))


Bumping Jay's challenge:
"Create a running game where the player has to press 2 keys a certain number of times as if they were controlling legs and it times the time taken to 'run' the distance as well as somehow showing progress to the finish "
0 Samuel Oloruntoba · September 26, 2014
def is_prime(num):
    prime = True 
    for i in range(2, num):
       if num % i == 0:
           prime = False
           break

    return prime
    
if is_prime(11):
    print('cool number')
else:
    print('this number sucks')

a simple function to check if a number is part of a fibonacci series.
0 Bor GS · September 26, 2014
def narcissistic(n):
    digitlist=list(str(n))
    for i in range(len(digitlist)):
        digitlist = int(digitlist)
        digitlist **= len(digitlist)   
    if sum(digitlist) == n:
        return True
    else:
        return False

print(narcissistic(input()))

Type a program that checks if the number is prime.
+2 Samuel Oloruntoba · September 3, 2014
@jay, you did not ask a question, so i guess i can ask but since i don't know what madlibs are here is my own rock paper scissors solution, it is quite bulky but you can check it out at this url(https://github.com/kayandrae/BR-ROCK_PAPER_SCISSORS/blob/master/main.py) my own question is, a word is chosen from by the computer from a group of words, this particular word is mis-arranged, the user has 3 chances to spell the right word.
0 Mason Farina · September 3, 2014

import random
userchoice = input("Please enter either rock, paper or scissors: ")
_enemyChoice = ["rock","paper","scissors"]
enemyChoice = _enemyChoice[random.randint(0,2)]
print("the computer chose: "+enemyChoice)
print("the player chose: "+userchoice)

if userchoice == "rock" and enemyChoice == "paper":
    print("the computer wins")
if userchoice== "rock" and enemyChoice== "rock":
    print("the it's a tie")
if userchoice== "rock" and enemyChoice== "scissors":
    print("the player wins")
if userchoice== "scissors" and enemyChoice== "rock":
    print("the computer wins")
if userchoice== "scissors" and enemyChoice== "scissors":
    print("its a tie")
if userchoice== "scissors" and enemyChoice== "paper":
    print("the computer wins")
if userchoice== "paper" and enemyChoice== "scissors":
    print("the computer wins")
if userchoice== "paper" and enemyChoice== "paper":
    print("its a tie")
if userchoice== "paper" and enemyChoice== "rock":
    print("the player wins")

Make a madlibs type game :)
0 Nikola Pantelić · September 3, 2014
num=371
num=str(num)
chars=len(num)
result=0
for i in range(0,chars):
    result+=int(num)**chars
if result==int(num):
    print('Number is narcissistic!')
else:
    print('Sorry, number is not narcissistic...')

Make a Rock, Paper, Scissors game!
0 Yoncho Yonchev · September 1, 2014
Anything more challenging will be nice. Providing alternative solutions for old tasks is fine too.

# Python 3.4, authour: yonchoy

# removing whitespaces from the input
sentence=str(input()).replace(" ", "")

# creating dictionary containing how many times each letter exist, unfortunately doesnt work for dublicates
#will show the last entered with the same key in the dictionary
def char_histogram(sentence):
    return {sentence.count(ch):ch for ch in set(sentence)}

my_dic=char_histogram(sentence)
print(my_dic[max(my_dic.keys())])





Program that checks if number is narcissistic (http://en.wikipedia.org/wiki/Narcissistic_number)
+2 Gary Murphy · August 29, 2014
http://colbertnation.mtvnimages.com/images/shows/colbert_report/videos/season7/mashups/cr_mashup_routines_I_did_it_v6.jpg


newNumber = ""
number = str(raw_input("Enter your number: "))
for i in number:
    newNumber = i + newNumber
if number == newNumber:
    print("The number is a palindrome")
else:
    print("The number is not a palindrome")


Write a piece of code that takes in any string and returns the most used character in that string.
0 Nikola Pantelić · August 27, 2014
Oh... I think I read it wrong! Nevermind, I will edit the code :D
+1 Eugene Botma · August 27, 2014
Nikola, a panagram is a sentence that uses all of the letters in the alphabet, repeating letters doesn't matter.
  • 1
  • 2

Python

121,018 followers
About

This section is all about snakes! Just kidding.

Links
Moderators
Bucky Roberts Administrator