Python for DS | Sept 16 | Nimisha

Discussion in 'Big Data and Analytics' started by Nimisha Pandey, Sep 16, 2019.

  1. Nimisha Pandey

    Nimisha Pandey Well-Known Member
    Alumni Trainer

    Joined:
    Aug 4, 2017
    Messages:
    80
    Likes Received:
    93
  2. Roopa R_1

    Roopa R_1 Member

    Joined:
    Aug 28, 2019
    Messages:
    6
    Likes Received:
    1
    Thank you for todays class. The start was very good.
     
    #2
  3. Nimisha Pandey

    Nimisha Pandey Well-Known Member
    Alumni Trainer

    Joined:
    Aug 4, 2017
    Messages:
    80
    Likes Received:
    93
    ### Rock Paper Scissor
    * Rock crushes Scissors
    * Scissors cuts Paper
    * Paper covers Rocks
    ##### Two player game:
    ##### take name and choice of the two players as input in a single statement
    ##### decide who wins
    ##### Print the winners with a short Congratulatory message
     
    #3
    Sudhir Bhalekar likes this.
  4. Prashant Kumar_38

    Joined:
    Jun 29, 2019
    Messages:
    3
    Likes Received:
    0
    if (choice1=='Scissor') and (choice2=='Paper'):
    print("Congratulations {} with {} choice wins".format(p1name,choice1))
    elif (choice1=='Rock') and (choice2=='Scissor'):
    print("Congratulations {} with {} choice wins".format(p1name,choice1))
    elif (choice1=='Paper') and (choice2=='Rock'):
    print("Congratulations {} with {} choice wins".format(p1name,choice1))
    else:
    print("Congratulations {} with {} choice wins".format(p2name,choice2))
     
    #4
  5. Vibhor Bhatnagar_1

    Vibhor Bhatnagar_1 New Member

    Joined:
    Jun 24, 2019
    Messages:
    1
    Likes Received:
    0
    print("Input the name and action of First Person")
    nameA, actionA = map(str, input().split())
    print("Input the name and action of Second Person")
    nameB, actionB = map(str, input().split())
    if actionA.upper() == "ROCK" and actionB.upper() == "SCISSOR": print(nameA, " wins")
    elif actionB.upper() == "ROCK" and actionA.upper() == "SCISSOR": print(nameB, " wins")
    elif actionA.upper() == "PAPER" and actionB.upper() == "ROCK": print(nameA, " wins")
    elif actionB.upper() == "PAPER" and actionA.upper() == "ROCK": print(nameB, " wins")
    elif actionA.upper() == "SCISSOR" and actionB.upper() == "PAPER": print(nameA, " wins")
    elif actionB.upper() == "SCISSOR" and actionA.upper() == "PAPER": print(nameB, " wins")
     
    #5
  6. Sarath S_1

    Sarath S_1 Member

    Joined:
    Jul 25, 2019
    Messages:
    2
    Likes Received:
    0
    while(1):
    count=0
    choice_1 = input('Enter your choice player - 1')
    choice_2 = input('Enter your choice player - 2')
    if (choice_1 == 'Q') or (choice_2 == 'Q'):
    break
    else:
    if(choice_1 == 'Rock') and (choice_2 == 'Scissor'):
    count = 1

    elif(choice_1 == 'Rock') and (choice_2 == 'Paper'):
    count = 2

    elif(choice_1 == 'Paper') and (choice_2 == 'Stone'):
    count = 1
    elif(choice_1 == 'Paper') and (choice_2 == 'Scissor'):
    count = 2

    elif(choice_1 == 'Scissor') and (choice_2 == 'Paper'):
    count = 1
    else:
    count = 2

    print(count)
    if count == 1:
    print('Congrats player-1')
    elif count == 2:
    print('Congrats player-2')
     
    #6
  7. Pritam mohapatra

    Joined:
    Sep 11, 2019
    Messages:
    3
    Likes Received:
    0
    name1,name2,choice1,choice2=input(),input(),input(),input()
    if choice1=='rock' and choice2=='scissor' or choice1=='scissor' and choice2=='rock':
    print("rock wins")
    result='rock'
    elif choice1=='scissor' and choice2=='paper' or choice1=='paper' and choice2=='scissor':
    print("scissor wins")
    result='scissor'
    elif choice1=='paper' and choice2=='rock' or choice1=='rock' and choice2=='paper':
    print("paper wins")
    result='paper'
    else:
    print("tied")

    if choice1==result:
    print("Congratulations,The winner is...",name1)
    else:
    print("Congratulations,The winner is...",name2)
     
    #7
  8. Trupti_9

    Trupti_9 New Member

    Joined:
    Aug 29, 2019
    Messages:
    1
    Likes Received:
    0

    players = {}
    for i in range(2):
    name, choice = input("Enter player name and choice: ").split()
    player_number = "player"+str(i+1)
    players.update({player_number:[name,choice]})

    choices = [players['player1'][1].lower(), players['player2'][1].lower()]
    if 'rock' in choices and 'scissor' in choices:
    if players['player1'][1].lower() == "rock": winner = players['player1'][0]
    else: winner = players['player2'][0]
    print(winner,"wins! Congratulations, Rock crushes Scissors...")
    elif 'paper' in choices and 'scissor' in choices:
    if players['player1'][1].lower() == "scissor": winner = players['player1'][0]
    else: winner = players['player2'][0]
    print(winner,"wins! Congratulations, Scissors cuts Paper...")
    elif 'paper' in choices and 'rock' in choices:
    if players['player1'][1].lower() == "paper": winner = players['player1'][0]
    else: winner = players['player2'][0]
    print(winner,"wins! Congratulations, Paper covers Rock...")
     
    #8
  9. Kailash Vaid

    Kailash Vaid New Member

    Joined:
    Jul 22, 2019
    Messages:
    1
    Likes Received:
    0
    #dict with key word
    Num = {1 : 'Rock', 2 : 'Paper', 3 :'Scissor'}

    # Boolen Logic to check: player can attempt 3 time
    Check = True

    #Game Rules
    print("Game Rule: ***You will get 3 attempt to input the rite number \n")

    #Giving Player to Choose Number 1 to 3
    print("Please Select any one number from 1 to 3\n",Num,"\n")

    #Requesting Player to start inputing the number
    play1 = int(input("Game Starts: Player One Please input number : "))

    #For Loop to check the attempts
    for a in range(1,4):
    if play1 <= 3:
    #Greeting is number is inbetween 1 to 3
    print("Thank you for making the rite choose \n")
    Check = True
    #Stop the For Loop
    break
    elif a == 3:
    #Setting Alerts to Player
    print("Game Over... Max Attempt done, Winner Player 2!!!...\n")
    Check = False
    else:
    #Giving Warning
    print("Incorrect Choose, Please input again\nYou have", 3 - a ,"attempt left\n")
    print("Please Select any one number from 1 to 3\n",Num,"\n")
    play1 = int(input("Player One Please input number : "))

    #2nd Player Logic Check
    if Check == True:
    #Giving Player to Choose Number 1 to 3
    print("Please Select any one number from 1 to 3\n",Num,"\n")
    play2 = int(input("Game Starts: Player Two Please input number : "))
    for a in range(1,4):
    if play2 <= 3:
    #Greeting is number is inbetween 1 to 3
    print("Thank you for making the rite choose \n")
    Check = True
    #Stop the For Loop
    break
    elif a == 3:
    #Setting Alerts to Player
    print("Game Over... Max Attempt done, Winner Player 1!!!...\n")
    Check = False
    else:
    #Giving Warning
    print("Incorrect Choose, Please input again\nYou have", 3 - a ,"attempt left\n")
    print("Please Select any one number from 1 to 3\n",Num,"\n")
    play2 = int(input("Player Two Please input number : "))
    #print("\n")

    #using player input number has index to find the choose name from the Dict
    choose1 = Num[play1]
    choose2 = Num[play2]

    #Same Match
    if choose1 == choose2:
    print('Player 1 have selected :',choose1,'\nPlayer 2 have selected :',choose2)
    print("Clash!!!!.... No Winner.... Same Choose...........")
    #Player 1 match with player 2
    elif choose1 == 'Rock' and choose2 == 'Paper' or choose1 == 'Scissor' and choose2 == 'Paper' or choose1 == 'Rock' and choose2 == 'Scissor':
    print('Player 1 have selected :',choose1,'\nPlayer 2 have selected :',choose2)
    print("Hurray we have got Winner!!!.... Player 1............")
    #Player 2 match with player 1
    elif choose2 == 'Rock' and choose1 == 'Paper' or choose2 == 'Scissor' and choose1 == 'Paper' or choose2 == 'Rock' and choose1 == 'Scissor':
    print('Player 1 have selected :',choose1,'\nPlayer 2 have selected :',choose2)
    print("Hurray we have got Winner!!!.... Player 2............")
     
    #9
  10. Sarath S_1

    Sarath S_1 Member

    Joined:
    Jul 25, 2019
    Messages:
    2
    Likes Received:
    0
    Hello Nimisha
    I am trying to do the assignment in pandas with the data set given in the simply learn portal. As you know it is a zip file. I tried the normal read_csv() to open it and i even extracted the zipfile to get an excel file and tried opening it with read_exel(). But as shown in the images i am getting a prompt saying that the "file is not in the specified folder ", which i a made sure thats not the case. I have tried putting ' / ' in place of ' \ ' and tried to get the data as raw data as well. It would be an great help if you cold guide me through it step by step.
    Regards
    Sarath S
     

    Attached Files:

    #10
  11. AMIT ARORA_5

    AMIT ARORA_5 Member

    Joined:
    Jun 28, 2019
    Messages:
    3
    Likes Received:
    0
    print(" Please select any one move: rock or scissor or paper ")
    Player1_Name,Player1_Move = input('Enter player 1 name and move=').split()
    Player2_Name,Player2_Move = input('Enter player 2 name and move=').split()
    print(Player1_Name,Player1_Move)
    print(Player2_Name,Player2_Move)
    if (Player1_Move == Player2_Move) : print("Its a tie between Player1_Name and Player2_Name ")
    elif ((Player1_Move == "rock" and Player2_Move == "scissor") or (Player1_Move == "scissor" and Player2_Move == "paper") or (Player1_Move == "paper" and Player2_Move == "rock")) : print('You won.Congratulations! ' ,Player1_Name)
    elif ((Player2_Move == "rock" and Player1_Move == "scissor") or (Player2_Move == "scissor" and Player1_Move == "paper") or (Player2_Move == "paper" and Player1_Move == "rock")) : print('You won.Congratulations! ' ,Player2_Name)
    else : print("please make a correct choice")


    Output >

    Please select any one move: rock or scissor or paper

    Enter player 1 name and move= Amit rock

    Enter player 2 name and move= Nimisha scissor

    Amit rock

    Nimisha scissor

    You won.Congratulations! Amit


    Please select any one move: rock or scissor or paper

    Enter player 1 name and move= Amit paper

    Enter player 2 name and move= Nimisha scissor

    Amit paper

    Nimisha scissor

    You won.Congratulations! Nimisha
     
    #11
  12. Ravikumar Purad

    Ravikumar Purad New Member

    Joined:
    Aug 8, 2019
    Messages:
    1
    Likes Received:
    0




    n=input("Please enter number of players")
    print(n)
    player1,choice1=input('Please enter player1 name and choose player1 options: Rock, Scissor, Paper ').split(',')
    player2,choice2=input('Please enter player2 name and choose playe2 options: Rock, Scissor, Paper').split(',')


    print('Player 1 - Name: ',player1,'and Choice: ',choice1)
    print('Player 2 - Name: ',player2,'and Choice: ',choice2)

    if choice1==choice2:
    print('Match tie')
    elif choice1 == "rock" and choice2 == "scissor":
    print('Rock Crushes Scissor')
    print('Congratulations to winner :' player1)

    elif choice1 == "scissor" and choice2 == "paper":
    print('Scissor Cuts Paper')
    print('Congratulations to winner :' player1)

    elif choice1 == "paper" and choice2 == "rock":
    print('Paper covers Rock')
    print('Congratulations to winner :' player1)

    elif choice1 == "scissors" and choice2 == "rock":
    print('Rock Crashes Scissor')
    print('Congratulations to winner :' player2)

    elif choice1 == "paper" and choice2 == "scissors":
    print('Scissor Cuts Paper')
    print('Congratulations to winner :' player2)

    elif choice1 == "rock" and choice2 == "paper":
    print('Paper covers Rock')
    print('Congratulations to winner :' player2)

    else:
    print('Please make the choice to play the game')
     
    #12
  13. santosh.alluri(3239118)

    Alumni

    Joined:
    Feb 21, 2014
    Messages:
    1
    Likes Received:
    0
    user1 = input("Enter your name and choice in (Rock/Paper/Scissors) with a space: ")
    user1 = user1.split()
    user1name = user1[0]
    user1choice = user1[1]

    user2 = input("Enter your name and choice in (Rock/Paper/Scissors) with a space: ")
    user2 = user2.split()
    user2name = user2[0]
    user2choice = user2[1]

    if user1choice == 'Rock' and user2choice == 'Scissors':
    Winner = user1name
    print(Winner)
    elif user1choice == 'Scissors' and user2choice == 'Rock':
    Winner = user2name
    print(Winner)
    elif user1choice == 'Paper' and user2choice == 'Scissors':
    Winner = user2name
    print(Winner)
    elif user1choice == 'Scissors' and user2choice == 'Paper':
    Winner = user1name
    print(Winner)
    elif user1choice == 'Rock' and user2choice == 'Paper':
    Winner = user2name
    print(Winner)
    elif user1choice == 'Paper' and user2choice == 'Rock':
    Winner = user1name
    print(Winner)
    elif user1choice == 'Rock' and user2choice == 'Rock':
    print("It is a tie!!! Please try again")
    elif user1choice == 'Paper' and user2choice == 'Paper':
    print("It is a tie!!! Please try again")
    elif user1choice == 'Scissors' and user2choice == 'Scissors':
    print("It is a tie!!! Please try again")
    else:
    print("Please enter a valid choice and try again")
     
    #13
  14. Navya Yenuganti

    Joined:
    Jun 25, 2019
    Messages:
    2
    Likes Received:
    0

    #Enter the details of first user with the choice
    UserDetails1= input("enter the name and choice(Rock/Paper/Scissors) with a space between them : ")
    UserDetails1=UserDetails1.split()
    username1=UserDetails1[0]
    Userchoice1=UserDetails1[1]

    #Enter the details of second user with the choice
    UserDetails2= input("enter the name and choice with a space between them : ")
    UserDetails2=UserDetails2.split()
    username2=UserDetails2[0]
    Userchoice2=UserDetails2[1]

    if((Userchoice1=='Rock')&(Userchoice2=='Paper')):
    print("Congratulations and the winner is " +username1)
    elif((Userchoice1 == 'Rock') & (Userchoice2 == 'Scissors')):
    print("Congratulations and the winner is " + username1)
    elif((Userchoice1 == 'Paper') & (Userchoice2 == 'Scissors')):
    print("Congratulations and the winner is " + username1)
    elif((Userchoice1 == 'Scissor') & (Userchoice2 == 'Rock')):
    print("Congratulations and the winner is " + username2)
    elif((Userchoice1 == 'Paper') & (Userchoice2 == 'Scissors')):
    print("Congratulations and the winner is " + username2)
    elif((Userchoice1 == 'Paper') & (Userchoice2 == 'Rock')):
    print("Congratulations and the winner is " + username2)
    elif ((Userchoice1 == 'Rock') & (Userchoice2 == 'Rock')):
    print("Its a tie!!! ")
    elif ((Userchoice1 == 'Paper') & (Userchoice2 == 'Paper')):
    print("Its a tie!!! ")
    elif ((Userchoice1 == 'Scissors') & (Userchoice2 == 'Scissors')):
    print("Its a tie!!! ")
    else:
    print("Please enter valid details")
     
    #14
  15. _67124

    _67124 New Member

    Joined:
    Aug 31, 2019
    Messages:
    1
    Likes Received:
    0
    name1, choice1 = input("Enter player 1 name and choice: ").split()
    name2, choice2 = input("Enter player 2 name and choice: ").split()
    if choice1 == 'rock':
    if choice2 == "rock":
    print("It's a tie")
    elif choice2=="paper":
    print(name2 ,"Won")
    else :
    print(name1 ,"Won")
    elif choice1 == "paper":
    if choice2 == "paper":
    print("It's a tie")
    elif choice2=="rock":
    print(name2 ,"Won")
    else :
    print(name1 ,"Won")
    else:
    if choice2 == "scissor":
    print("It's a tie")
    elif choice2=="rock":
    print(name2 ,"Won")
    else :
    print(name1 ,"Won")
     
    #15
  16. Christy Kiran P

    Christy Kiran P New Member

    Joined:
    Sep 9, 2019
    Messages:
    1
    Likes Received:
    0
    Criteria = ["Rock", "Paper", "Scissor"]
    Christy = ["R", "P", "S"]


    import random

    while True:
    Christy_Choice = input ("Your Choice : ")
    if Christy_Choice == "E":
    break
    Computer_Choice_Criteria = random.choice(Criteria)

    print ("Me : ", Christy_Choice)
    print ("Computer : ", Computer_Choice_Criteria)

    if Christy_Choice in Christy == Computer_Choice_Criteria :
    print ("Its Tie")


    # -- ROCK ----- #if Christy_Choice in Christy [0] and Computer_Choice_Criteria in Criteria[1]:
    print ("Christy, You lose!")
    elif Christy_Choice in Christy [0] and Computer_Choice_Criteria in Criteria[2]:
    print ("Christy, You Win!")

    # -- Paper -----#if Christy_Choice in Christy [1] and Computer_Choice_Criteria in Criteria[0]:
    print ("Christy, You Win!")
    elif Christy_Choice in Christy [1] and Computer_Choice_Criteria in Criteria[2]:
    print ("Christy, You lose!")

    # ----Scissor -------#if Christy_Choice in Christy [2] and Computer_Choice_Criteria in Criteria[0]:
    print ("Christy, You lose!")
    elif Christy_Choice in Christy [2] and Computer_Choice_Criteria in Criteria[1]:
    print ("Christy, You Win!")
     

    Attached Files:

    #16
  17. Gunjan Singh Rawat

    Joined:
    Aug 26, 2019
    Messages:
    2
    Likes Received:
    0
    player1_name, player1_option, player2_name, player2_option = input("Players, Please enter your Name and options as Scissors OR Rock OR Paper: ").split(',',4)
    if (player1_option == 'Rock' and player2_option == 'Scissors') \
    or (player1_option == 'Scissors' and player2_option == 'Paper') \
    or (player1_option == 'Paper' and player2_option == 'Rock') :
    print("Congrats " + player1_name + " for winning the game")
    elif player1_option == player2_option :
    print("Game draw")
    else : print("Congrats " + player2_name + " for winning the game")
     
    #17
  18. Abhishek G S

    Abhishek G S New Member

    Joined:
    Aug 20, 2019
    Messages:
    1
    Likes Received:
    0
    ma'am,
    The recordings aren't available yet. session 3 was the last uploaded recording
    i also have raised the ticket too and nobody as responded.
     
    #18

Share This Page