Showing posts with label Canopy. Show all posts
Showing posts with label Canopy. Show all posts

Wednesday, June 1, 2016

Jawaban L3 Problem 9 - Intro to Computer Science & Programming Using Python - edx.org



Jawaban raw Hisoka kyk gini :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import random

low = 0;
high = 100;
ans = 0;

print("Haay.. I'm Hyosoka's awesome guess number");
print("So...Please Choose number between 0 and 100....Then I'm gonna guess your secret number... :D");
print("Done...? y or n");
usr=raw_input();
while(usr == "n"):
    print("Please Choose number between 0 and 100....");
    print("Done...? y or n");
    usr=raw_input();

ans = random.randint(0,100);    
print("Is your secret number = " + str(ans));
print("");
guess = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly");
while (guess != "c"):    
    if( guess == "h"):
        high=ans;
        ans = (low+high)/2;
    elif(guess == "l"):
        low = ans;
        "high = 100;"
        ans = (low+high)/2;
    else:
        while((guess != "h") or (guess != "l")):            
            print("Sorry... I don't understand your input");
            guess = raw_input("Please just enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low ");
            if(guess == "h" or guess == "l"): break;
    print("Is your secret number = " + str(ans));
    guess = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly");

print("Yeeei... So your secret number is = "+str(ans) +" heheh... :D");                

Yang itu udah ditest... dan berhasil... nah pas dimasukin ke edx-nya diubah jadi kyk gini :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
low = 0;
high = 100;
ans = 0;

print "Please think of a number between 0 and 100!"

ans = 50;    
print("Is your secret number = " + str(ans));
print("");
guess = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly");
while (guess != "c"):
    if( guess == "h"):
        high=ans;
        ans = (low+high)/2;
    elif(guess == "l"):
        low = ans;
        "high = 100;"
        ans = (low+high)/2;
    else:
        while(guess != "c" or guess != "h" or guess != "l"):
            print("Sorry... I don't understand your input");
            guess = raw_input("Please just enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly");        
            if(guess =="h" or guess =="l"): break;
    print("Is your secret number = " + str(ans));
    guess = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly");

print("Game over. Your secret number was: "+str(ans));    

Cuman dianggap salaah.... :v seharusnya udah bener, soalnya udah ditest di canopy... :v


Mmmm.... tapi udah ngelapor... ehehe... :D
Btw... jawaban dari edx-nya seperti ini :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
print("Please think of a number between 0 and 100!")

# At the start the highest the number could be is 100 and the lowest is 0.
hi = 100
lo = 0
guessed = False

# Loop until we guess it correctly
while not guessed:
    # Bisection search: guess the midpoint between our current high and low guesses
    guess = (hi + lo)/2
    print("Is your secret number " + str(guess)+ "?")
    user_inp = raw_input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ")

    if user_inp == 'c':
        # We got it right!
        guessed = True
    elif user_inp == 'h':
        # Guess was too high. So make the current guess the highest possible guess.
        hi = guess
    elif user_inp == 'l':
        # Guess was too low. So make the current guess the lowest possible guess.
        lo = guess
    else:
        print("Sorry, I did not understand your input.")

print('Game over. Your secret number was: ' + str(guess))

Sekian dulu... :)

Wednesday, March 23, 2016

Canopy at First Sight

Downloadnya di sini :
https://store.enthought.com/downloads/#default
Terusss...steleh selese.. double click...





Teruss.... pas dijalankan pertama kali...



 Setelah tekan "Editor" seperti yang ditunjukin panah diatas, akan muncul kayak gini...
Naaaah... silahkan masukin kode2 basic python seperti terlihat di bawah...
Terus klu coba mw dibikin di file, tekan yang tombol create file seperti terlihat pada panah hijau di atas terus masukin kode yg sederhana :
Terus tekan tombol run seperti yg ditunjukin panah ijo diatas, daaan hasilnya :
Okkkieee... mungkin seperti ini dl ajjah previewnya.. .. :)
Semoga bermanfaaat... :)