No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
14 Posted Topics
########################################################### # Python program that would display larger of two numbers # ########################################################### def Max(arg1,arg2): if arg1 > arg2: return arg1 else: return arg2 print "Enter first number:", a = int (raw_input("> ")) print "Enter second number:", b = int (raw_input("> ")) Max_value = Max(a,b) print "The greater of the …
just to help you, - declare a counter = 0, - array of numbers = [], - while counter < 20 - take input from users - array.append(input) - print the array - use min function to find lowest number in array - use max function to find greatest number …
I am stuck on the final part of the query, I know that this thing is easy, but I am out of ideas now, so sorry for this. I have prepared a query like this: SELECT A.projectName as PARENT, (select COUNT(*) from PSPROJECTITEM WHERE PROJECTNAME = A.PROJECTNAME) parentprojecount, B.ProjectName as …
I have written the following code for Towers of Hanoi problem using non recursive approach. I guess it is not correct as the number of moves are not 2*n - 1, for eg, for 3 disks to be moved, it has to generate 7 moves. Thanks in advance. ###################### # …
post the file first, so that i can develop the program. and to read a line with a paritcular string in python, we use startswith(str) function. for line in readlines(): if line.startswith("joker"): operations
try with importing a module named urllib. i will try to fix this though
myList = ['1','2','a','b'] mylist = ' '.join(list for list in myList) print "['" + mylist.replace(' ',"','") + "']" output: PS C:\Users\rk\pythonprograms> python lists.py ['1','2','a','b'] PS C:\Users\rk\pythonprograms>
> text = str(raw_input('ttwtf$ ') text = str(raw_input('ttwtf$ ')) is the correct method
0 down vote favorite I have written a code to convert decimal numbers into hexadecimal equivalent. The program prints correct value till '2559'. How to get correct values of hexadecimal for larger numbers. Here is my code: ######################################### # Decimal to Hexadecimal Conversion # ######################################### def DectoHex(n): if n <= …
I am learning Python through LPTHW. There is an exercise where we need to create test scenarios. The following is the code for whom Test Case have to be made: ############################# # Sentence Parser # ############################# class ParserError(Exception): pass class Sentence(Object): def __init__(self, subject, verb, object): # remember, we take …
A basic program which writes the user name who has logged in the windows machine: ###################### # User info # ###################### import os import datetime from time import strftime def foo(): usr_log = os.environ ['USERNAME'] sys_log = os.environ ['USERPROFILE'] current_time = strftime("%a, %d %b %Y %H:%M:%S") dt_str = str (datetime.date.today()) …
################################# # Learning to make a game # ################################# # An attempt to make a game # Each room will be described by a class, whose base class will be Room # The user will be prompted to enter a number, each number will be assigned with a Room in …
Hope this solves this, if your desired output is 1247.12: # This program demonstrates the split method. def main(): # Create a string with multiple words. my_string = '1247.123456789' # Split the string. number_list = my_string.split('.') print number_list firstString = number_list[0] print firstString secondString = number_list[1] secondString = secondString[0 : …
The End.