Skip to main content

How to make calculator in python kivy

  How make calculator in python We make a calculator in python using kivy module . Kivy module helps us to make android apps . First wait , If you run a kivy program in your terminal then you see a error like this To solve this problem you have to go kivy docs and follow the instruction of kivy docs.  First we have to make a virtual environment and then in the virtual environment you have to install kivy . After that you have to write  kivy_venv\Scripts\activate in your terminal and then run the file . If this method not work then write the comment below. LETS START CODING First we import kivy .For this we hve to write  from  kivy.app  import  App from  kivy.uix.label  import  Label from  kivy.uix.button  import  Button from  kivy.core.window  import  Window from  kivy.uix.gridlayout  import  GridLayout from  kivy.uix.widget  import  Widget from  kivy.lang  import ...

HOW TO MAKE ROCK PAPER SCISSOR GAME IN JAVA

  What is Rock Paper Scissor game?

Rock paper scissor game is hand game played between two players ,in each player at the same time forms one of three shapes.

Rock Paper Scissor game in java 

When we want to rock paper scissor game with computer what we do for this 

we make a computer program with the help of java.

LETS START CODING

We use while loop to play  game five times after that calculate the points of both user and computer then print the winner and there points.

In this game we take 0 for stone, 1 for paper, 2 for scissor.

import java.util.Random

We have to import random module to generate the computer choice. simply ,we have to write import java.util.Random; to import random module.

Taking user input 

For taking input from the user we have to import import java.util.Scanner;

After that we have to write System.out.println("Enter your play:");

            Scanner sc = new Scanner(System.in);
            int userplay = sc.nextInt();

MAKING  COMPUTER CHOICE 

For computer choice we have to write  Random r=new Random();

            int computerplay = r.nextInt(3);


GAME CONDITION 

For game condition and determine winner we have to use IF ,ELSE condition .

When user input is equal to 0(rock) and computer input is 1(scissor) then user wins.

When user input is equal to 1(scissor) and computer input is 2(paper) then user wins.

When user input is equal to 2(paper) and computer input is 0(rock) then user wins.

When user input is equal to 0(rock) and computer input is 1(paper) then computer wins.

When user input is equal to 1(scissor) and computer input is 0(rock) then computer wins.

When user input is equal to 2(paper) and computer input is 1(scissor) then computer wins.

When user input is equal to computer input then display "Its tie".

When user enter other input then display "enter valid number".

After while loop complete we calculate the points of user and computer and print the winner and there points.

HERE ARE THE CODE




OUTPUT