Demo entry 6780990

Tariq Ex 3

   

Submitted by Tariq on Dec 30, 2018 at 23:06
Language: Python 3. Code size: 2.2 kB.

#Q1
roses_color= input('What is the color of roses?  ')
violets_color= input('What is the color of violets ?  ')
sugar_taste= input('What is the tase of sugare?  ')
if (roses_color.lower()== 'red' and violets_color.lower() == 'blue' and sugar_taste.lower() == 'sweet'):
        print ('So are you !')
else:
    print ('you are sweet..but try again')

#Q2
paly_again= True
while paly_again == True:
    p1_choice= ''
    p2_choice= ''
    while p1_choice.lower() not in ('r','p', 's'):
        p1_choice= input('''
                        Player 1>>>  What is your choice?
                        Rock (press: r)
                        Paper (press: p)
                        Scissors (press: s) 
                        ''')
    else:
        print ('ok')


    while p2_choice.lower() not in ('r','p', 's'):
        p2_choice= input('''
                        Player 2>>>  What is your choice?
                        Rock (press: r)
                        Paper (press: p)
                        Scissors (press: s) 
                        ''')
    else:
        print ('ok')

    def result(x,y):
        if x==y:
            return( 'It is a Draw')
        elif (x=='p' and y=='r') or (x=='r' and y=='s') or (x=='s' and y=='p' ):
            return ('Congratulations Player One')
        else:
            return ('Congratulations Player Two')

    print(result(p1_choice, p2_choice))
    check_playing= input('If you want to play press y ')
    if check_playing.lower() not in ('y'):
        print('Game Over')
        paly_again= False


#Q3
chance= 5
import random
my_random= random.randint(1,100)
while chance !=0:
    guess= int(input('Please guess a number between 1 and 100: '))
    if guess== my_random:
        print ('Great. you got it right !')
        chance= 0
    elif guess > my_random:
        print ('Try lower')
        chance -= 1
    else:
        print ('try higher')
        chance -=1
else:
    print ('By')

    

#Q5
import string
char= string.ascii_lowercase
x=26
while x> 0:
    print(char[:x])
    x-=1

y=0
while y<26:
    print(char[y:])
    y+=1

z=1
while z<13:
    print(char[z:-z])
    z+=1

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).