Ubuntu Türkiye

Diğer Dağıtımlar => Ubuntu Touch => Konuyu başlatan: ogulcan_19033 - 08 Mayıs 2017 - 09:58:44

Başlık: python
Gönderen: ogulcan_19033 - 08 Mayıs 2017 - 09:58:44
ACİLLLLLL python taş kağıt makas oyununu fonksiyonlu bişekilde kodunu gönderebilirmisiniz şimdiden teşekkürler
Başlık: Ynt: python
Gönderen: freeman - 08 Mayıs 2017 - 10:41:18
AL
python taş kağıt makas (http://lmgtfy.com/?q=python+rock+paper+scissors)
Başlık: Ynt: python
Gönderen: lrnyrd - 08 Mayıs 2017 - 10:42:30
[mention=624990]@ogulcan_19033[/mention] Birincisi konu yanlış yerde ikincisi buraya gelip hazıra konmak yerine internetten araştırabilirsin.


Mesaj tekrarı yüzünden mesajınız birleştirildi. Bu mesajın gönderim tarihi : 08 Mayıs 2017 - 10:43:16

[mention=624991]@freeman[/mention] tebrikler bütün duygularıma tercüman oldunuz.  ;D
Başlık: Ynt: python
Gönderen: ogulcan_19033 - 08 Mayıs 2017 - 10:56:08
hazıra konmuyorum kodum var fakat fonksiyona çeviremedim yardım istiyorum



# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""
import random


print(("-" * 30) + "\ntas, kagit, makas\n" + ("-" * 30))


user_score, computer_score = 0, 0


while True:

    print("\n1 - tas\n2 - kagit\n3 - makas")

    user_choice = raw_input("Your choice: ")

    computer_choice = random.choice(["1", "2", "3"])

   

    if user_choice == "1":

        if computer_choice == "1":

            print("Computer's choice: tas\ntas equal to rock. Scoreless!")

           

        elif computer_choice == "2":

            print("Computer's choice: kagit\nkagit sarar . You lose!")

            computer_score += 1

           

        elif computer_choice == "3":

            print("Computer's choice: makas\ntas kırar scissors. You win!"user_score += 1)

            user_score += 1

           

    elif user_choice == "2":

        if computer_choice == "1":

            print("Computer's choice: tas\nkagit sarar . You win!"user_score += 1)

         

           

        elif computer_choice == "2":

            print("Computer's choice: kagit\nkagit equal to paper. Scoreless!")

           

        elif computer_choice == "3":

            print("Computer's choice: makas\nmakas keser paper. You lose!"user_score += 1)

         

           

    elif user_choice == "3":

        if computer_choice == "1":

            print("Computer's choice: tas\ntas kırar scissors. You lose!")

         

           

        elif computer_choice == "2":

            print("Computer's choice: kagit\nmakas keser paper. You win!")

            user_score += 1

           

        elif computer_choice == "3":

            print("Computer's choice: makas\nmakas equal to scissors. Scoreless!")

   

    else:

        break

   

print("\nUser's score: {}\nComputer's score: {}".format(user_score, computer_score))


Mesaj tekrarı yüzünden mesajınız birleştirildi. Bu mesajın gönderim tarihi : 08 Mayıs 2017 - 11:20:44

fonksiyona çevirdim fakat hatalar veriyor destek verirmisinizx
# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""


#import random module
import sys



user1 = input("adınız ne?")
user2 = input("ve sizin adınız?")
user1_answer = input("%s, tas kagit makas hangisi?" % user1)
user2_answer = input("%s, tas kagit makas hangisi ?" % user2)

def compare(u1, u2):
    if u1 == u2:
        return("hebe!")
    elif u1 == 'tas':
        if u2 == 'makas':
            return("taş kazandı!")
        else:
            return("kagıt kazandı!")
    elif u1 == 'makas':
        if u2 == 'kagıt':
            return("makas kazandı!")
        else:
            return("taş kazandı!")
    elif u1 == 'kagıt':
        if u2 == 'tas':
            return("kagıt kazandı!")
        else:
            return("makas kazandı!")
    else:
        return("gecersiz giris! girmediniz tas, kagıt veya makas, tekrar deneyin.")
        sys.exit()

print(compare(user1_answer, user2_answer))
Başlık: Ynt: python
Gönderen: semm - 08 Mayıs 2017 - 11:44:06
return leri print yapmalısın inputlarıda fonksiyon içerisine al dene
Başlık: Ynt: python
Gönderen: Barlow - 08 Mayıs 2017 - 19:39:24
Kod Etiketi Kullanımı (https://forum.ubuntu-tr.net/index.php?topic=14283.0)

Yazdığınız uygulama kodunu Code etiketi içerisinde yazarsanız, daha okunaklı olacağı kanısındayım. Bu arada foruma hoşgeldiniz..