Friday, 3 February 2017

Bubble Sort Program in Python

In bubble sorting first and second elements are compared if first one is greater than second one then both are exchanged, here below 25 is greater than 15 so their position is exchanged.
Then the second and third elements are compared but not like above case here 25 is not greater than 36 then nothing will happen here. and so on.

First Iteration
Bubble Sorting

Bubble Sort Program in Python:

print 'Bubble Sorting'
print 'Enter the element of the list and write 'done/Done' to stop'
loop = True
list = []
while loop == True:
lis = raw_input()
if lis == 'done' or lis=='Done':
loop =False
else:
list.append(int(lis))
leng = len(list)
print leng
for i in range(0,leng):
for j in range(0,leng):
if j < leng-1:
if list[j] > list[j+1]:
a = list[j]
list[j] = list[j+1]
list[j+1]=a
print 'Sorted list will be',list



Friday, 30 September 2016

Game of Rock Paper Scissors in Python

Rock Paper Scissors (Python)

import random
lst = ['rock','paper','scissors']
print "\n\n Rock, Paper and Scissors \n\n"
print "\n You are playing vs Computer\n"
user = raw_input("Enter yr name:")
while(True):

    user1 = raw_input("%s, do yo want to choose rock, paper or scissors?" % user)

    if user1 not in lst:
        print "Invalid Input(Please input exaclty words givne to choose)"
    computer = random.choice(lst)
    if user1 in lst:
        print 'Computer chooses', computer
    if computer == user1:
        print 'Its a Tie'
    if computer == 'rock' and user1 == 'paper':
        print '\n\n%s Wins\n\n' %user
    if computer == 'rock' and user1 == 'scissors':
        print '\n\nComputer Wins\n\n'
    if computer == 'paper' and user1 == 'rock':
        print '\n\nComputer Wins\n\n'
    if computer == 'paper' and user1 == 'scissors':
        print '\n\n%s Wins\n\n' %user
    if computer == 'scissors' and user1 == 'rock':
        print '\n\n%s Wins\n\n' %user
    if computer == 'scissors' and user1 == 'paper':
        print '\n\nComputer Wins\n\n'
    print 'Play again(yes/no)'
    user_play_again = raw_input('\nEnter(yes or no):\n')
    if user_play_again == 'yes':
        continue
    else:
         print '\n\nGame Over\n\n'

         break



OUTPUT:


Game of Rock Paper Scissors

Monday, 26 September 2016

Python Odd/Even Program

Program to check that the no. entered by user is odd/even. 

while(True):
    num = raw_input("Enter the number that you want to test for even/odd:\n")
    num = int(num)
    even_odd = num % 2
    if even_odd == 0:
        print "\n\nYour entered number is Even\n\n"
    else:
        print "\n\nYour entered number is Odd\n\n"


OUTPUT:


Thursday, 22 September 2016

How to install python 2.7 on windows???

Python Installation

1.  First of all download the python version 2.7 from here here  (Pythons 2.7 latest version is 2.7.12) .

2.Click on python 2.7.12

Python Installation

    .exe file will download on your pc/laptop.


3.  Click on the downloaded .exe file.

To be Cont.

 

 


Monday, 1 June 2015

Welcome to Python for Beginners...

Python for Beginners

Hello guyz this tutorial is for beginners who want to learn python.

What do u should know before learning python programming language?
  
  1. If you are new to programming world just learn python from very beginning.
  2. If you already done some language before python then you can skip some basic or common topics which are covered by every programming language.
  3. Basic Knowledge of HTML.
  4. Basic knowledge of css.
to learn HTML and CSS.
To be cont...