15,181 Topics

Member Avatar for
Member Avatar for jeremywduncan

def is_anagram(t,u): if sorted(t)== sorted (u): return True else: return False print is_anagram('realtor', 'rotlear') # True print is_anagram('superpuff','local') # False print is_anagram('alla', 'lala') # True print is_anagram('tools', 'stool') # True print is_anagram('double', 'trouble') # False

Member Avatar for TrustyTony
-1
779
Member Avatar for jeremywduncan

def is_sorted(t): if t == sorted(t): return True else: return False print is_sorted([1,2,2]) # True print is_sorted(['b','a']) # False print is_sorted([3, 1, 5, 2, 4]) # False print is_sorted(['d', 'a', 'c', 'b']) # False print is_sorted(['a', 'b', 'b', 'd', 'e', 'e', 'f', 'g']) # True

Member Avatar for jeremywduncan
0
824
Member Avatar for MasterHacker110

What are advantieges of Ruby over Python and vise versa? Then in your opinion wich one is better for all around programming on linux and windows?

Member Avatar for Ene Uran
0
189
Member Avatar for vegaseat

Let's imagine you are taking a lot of pictures and modify them with one of those fancy image editors. You burned the image files to a CD, and decided to purge some of the outdated files because your hard drive is getting full. This Python code allows you to set …

Member Avatar for Ene Uran
0
531
Member Avatar for SteveA

I am trying to work out how to remove files from a directory the files will always have a given extention e.g .txt I want to remove the filesfrom a specific directory that are older than say 14 days. Noob to Python sorry if this has been answered elsewhere, all …

Member Avatar for Ene Uran
0
305
Member Avatar for mahesh.venkateshwaran

I am writing an application that requires to ssh and telnet to a device at the same time. The pseudo code goes something like this. p1 = pexpect.spawn("ssh to the device") p1.send("run some command") p1.expect("..") p2 = pexpect.spawn("telnet to same device") p2.send("run a command that can be run only through …

0
52
Member Avatar for mrpython1

Im thinking about making a little system for an imaginary retailer, Im going to have a section for the employers and there sales figures, Was just wondering If there was something like an import function for graphs? Im a bit of a noob so go easy

Member Avatar for vegaseat
0
530
Member Avatar for Jacklittle01

I am developing a text based rpg, but do not know how to go to different def statement, but it says it is not defined. Help?

Member Avatar for Jacklittle01
0
135
Member Avatar for Mclovin

I'm struggeling with a problem which probably is farely easy to solve. I just cant find a simple way to do it. I want to be able to recognize the occurance of digits in a string. Lets say the string looks like: [CODE] file_Name1 = 'abc123de' file_Name2 = 'qwe987rty' [/CODE] …

Member Avatar for Lucaci Andrew
0
2K
Member Avatar for sugarzzzz

def verifyNeighbor (boardWidth, boardHeight, neighbor, me): my_row=me/boardWidth neighbor_row=neighbor/boardWidth if my_row==neighbor_row and abs(me-neighbor)==1: result=True else: result=False my_column=me/boardHeight neighbor_column=neighbor/boardHeight my_column=neighbor_column if my_column==neighbor_column and abs(me-neighbor)==boardHeight: result=True else: result=False x=boardWidth*boardHeight if neighbor>x: result=False else: result=True if neighbor<0: result=False else: result=True return result given a board of height like 4,5 etc and a width of …

Member Avatar for lancevo3
0
227
Member Avatar for mrpython1

Im trying to create a booking system for a cinema, What i want to do is : open my csv with available seats, print it then ask the user what seat it wants, then the csv need to update taking away the seat, and then that seat gets added to …

Member Avatar for longtomjr
0
4K
Member Avatar for dp121307

So I made the login program that reads the usernames and password from a file (names.txt). The program works correctly. But my problem is I want to ask give the user 3 chances to get the username right before the program closes and 10 chances to get the password right …

Member Avatar for dp121307
0
200
Member Avatar for Octet

Hello Daniweb, I'm beginning to learn Python, which I hope shall be a useful tool to help with server administration and the such. I am however having some problems, I'm sure this is a very simple problem but I can't see what is going wrong. #!/usr/bin/env python3.3 validSelection = 0 …

Member Avatar for Octet
0
208
Member Avatar for vegaseat

A simple code example to calculate the monthly payment on a mortgage loan. Takes a look at Python's newer print and format functions.

4
9K
Member Avatar for krystosan

Can anyone please suggest me best practice to create a Custom widget using QtDesigner? I want to see how to approach adding Qpushbutton or QCheckboxGroup inside the cells of QTable Widgets that will be added on user clicking add new row to QTable at runtime

Member Avatar for vegaseat
0
148
Member Avatar for ichi0915

I want to add a total paid variable to my code, but i couldnt think of any formula to sum the minimum payments and give me a total, my code is program to calculate the credit card balance after one year if a person only pays the minimum monthly payment …

Member Avatar for TrustyTony
0
166
Member Avatar for anton.yakushin

I am wondering if anyone could recommend the best CMS for an Airbnb-style marketplace that allows people to sublet their apartments, and other people to search, filter, and pay for the apartments listed. These are the main requirements: - Ability to sign up both buyers and sellers. - Accounts for …

Member Avatar for LastMitch
0
241
Member Avatar for omer.tzuk

Hello, I am new to Python and have a mission impossible to a beginner, I need to import a specific table from a source code written in LaTex. I tried to start this code in this way : import asciitable from sys import argv def searching_table(table_identifier): with open(fname, "r") as …

Member Avatar for TrustyTony
0
214
Member Avatar for bumsfeld

This shows the code for one simple crypt of text by swapping two adjoining characters each. You can make that more complex if you like. Can also be used for one nice riddle.

Member Avatar for bumsfeld
2
628
Member Avatar for Gribouillis

This snippet defines a Print function which can be used with python 2.4, 2.5, 2.6 and 3.0 (for 3.0 this is just the built-in print function). It's interface is that of the python 3.0's print. It simplifies the task of writing transitional code which runs under python 2.5 and python …

Member Avatar for Lucaci Andrew
1
801
Member Avatar for superbhimanshu

Hi all, I have a list of dates (in MM-DD-YYYY format). I want to sort the list by months ignoring day an year and look the frequency plot by months that is how many dates correspond to January, February and so on. Please Help me ! thanks Himanshu

Member Avatar for TrustyTony
0
72
Member Avatar for vegaseat
Member Avatar for HiHe
3
625
Member Avatar for Fernando_1

# VARIABLE DEFINITIONS name="" adress="" city="" state="" zipcode="" course1="" course2="" course3="" course4="" course5="" #----------------------------------------------------------------------- # CONSTANT DEFINITIONS courses= "Enter courses name (Type 'STOP' when finished) :" pointsR = "\tEnter points received ( Type '9999' when finished) :" pointsP = "\tEnter points possible for this assignment :" #----------------------------------------------------------------------- # FUNCTION DEFINITIONS …

Member Avatar for woooee
0
177
Member Avatar for longtomjr

Ok this is a suggestion... If someone post here in the python forum the must have a tickbox to choose what version of python they use... This will make it esier to see if you'll be able to help Kind regards Longtomjr

Member Avatar for longtomjr
0
180
Member Avatar for amweasel

I have been trying to make a simple "quiz" program on Python. And this is what I coded: print("Mathematics Quiz") question1 = "Who is president of USA?" options1 = "a. Bharat Chauhan\nb. His dad\nc. His mom\nd. Barack Obama\n" print(question1) print(options1) while True: response = input("Hit 'a', 'b', 'c' or 'd' …

Member Avatar for amweasel
0
464
Member Avatar for TrustyTony

Here is my celebration post for entering level 3 in Project Euler. Again I left in my debug prints. I am in process of adapting myself to new .format style of formatting. I have commented out the prints though to get visible the running time of the functions own action. …

Member Avatar for TrustyTony
0
696
Member Avatar for dp121307

I have to make a login program where the username and password are taken from an existing file. I have successfully, in my opinion, opened, read, and brought out all the user names and passwords from the file. The problem is, the user is only allowed to input an incorrect …

Member Avatar for woooee
0
2K
Member Avatar for HiHe

Explore the Python module bisect to search a sorted list and insert elements in the proper location in a sorted list.

Member Avatar for TrustyTony
3
632
Member Avatar for krystosan

I recently made an appication that utilizes pyqt , i could say i wrote the code pythonic and made everything work work as I wanted, but didnt used any data model , so later I realized I could have used data model since I am building list in the QListView …

Member Avatar for krystosan
0
230
Member Avatar for rexmorgan

Good Day, I have a text file in the .csv format. The file originates as a xlsx (excel) file type. The file looks something like the following. Name Number Lat Long Jan Feb Mar Apr Brockton 24-1670-06 38.145236 145.854921 0.15 0.62 1.25 2.14 Westby 24-7432-04 35.846125 132.743652 0.25 0.94 1.14 …

Member Avatar for rexmorgan
0
3K

The End.