How To Write or Store Data In Exel Sheet Excel Sheet Using Python. Source Code: import xlwt from xlwt import Workbook # Workbook is created wb = Workbook() # add_sheet is used to create sheet. sheet1 = wb.add_sheet('Sheet 1') sheet1.write(1, 0, 'Shivam') sheet1.write(2, 0, 'Haris') sheet1.write(3, 0, 'Arjun') sheet1.write(4, 0, 'Noman') sheet1.write(5, 0, 'Anish') sheet1.write(0, 1, 'anil') sheet1.write(0, 2, 'Kaus') sheet1.write(0, 3, 'aman') sheet1.write(0, 4, 'Anurag') sheet1.write(0, 5, 'sarvesh') wb.save('xlwt example.xls') OUTPUT
Posts
- Get link
- X
- Other Apps
-- Dice Rolling Simulator using Python-random Source Code import random a = input("Press Y To Roll The Dice :") print("\n") def random_number(): n = random.randint(1,6) if n == 1: print("-------") print(" ") print(" 0 ") print(" ") print(" ") print("-------") elif n == 2: print("-------") print(" 0 ") print(" ") print(" ") print(" 0 ") print("-------") elif n == 3: print("-------") print(" 0 ") print(" 0 ") print(" 0 ") print("-------") elif n == 4: print("-------") print("0 ") print(" 0 ") print("
- Get link
- X
- Other Apps
Problem: The Goal: Like the title suggests, this project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integer you prefer — the number of sides on the die is up to you.) The program will print what that number is. It should then ask you if you’d like to roll again. For this project, you’ll need to set the min and max number that your dice can produce. For the average die, that means a minimum of 1 and a maximum of 6. You’ll also want a function that randomly grabs a number within that range and prints it. Solution: import random def random_number(): n = random.randint( 1 , 6 ) var = input( "Press Enter button to get the number" ).lower() if var== "" : print(n) else : print( "try again" ) while True : random_number()