Skip to main content

All Questions

5 votes
1 answer
213 views

Compute the mean of a series of user-entered numbers

Which is more elegant out of two methods as mentioned below mostly from memory prospective? Both methods achieve the same result, but from a memory perspective, In Method1, we are storing the running ...
Karn Kumar's user avatar
2 votes
3 answers
107 views

Wordlist formatter code

I am making a "wordlist cleaner" module that loads a words.txt file, and returns a list of cleaned/sorted words. Full code: ...
angel's user avatar
  • 35
1 vote
1 answer
203 views

Excluding attributes entirely vs. setting them to None

I am making a program that parses profiles from a website. Some profiles are "public" and others are "private" with limited information. Public profiles contain a lot more data and ...
angel's user avatar
  • 35
3 votes
2 answers
930 views

Convert Rankine temperatures to Celsius

I have this Python Package called ToTemp under development for precise Temperature Conversions and currently thinking in changing the method's implementation to be ...
eddyxide's user avatar
  • 141
0 votes
1 answer
71 views

Comparison of two ways of looping in Python [closed]

I wrote a small script to demonstrate two ways of looping in Python: with and without using the index. I want to know which way is better. Please see the example: ...
Jeremy's user avatar
  • 111
2 votes
4 answers
1k views

Calculate the median value of combining two sorted lists

I have solved a leetcode problem (Median of Two Sorted Arrays), and I came up with two solutions. Solution 1 ...
111's user avatar
  • 45
2 votes
1 answer
153 views

LeetCode#494 target sum (dart is slower than python)

I'm trying to solve a LeetCode problem target-sum, in two languages: Python & Dart. The difference of time taken is shocking for me" Python took ~70ms while Dart took ~900ms !! Why does Dart ...
Abhishek Patil's user avatar
5 votes
1 answer
330 views

Calculate the number of people occupied at each time interval

The following scripts calculate a list with the number of people occupied at each time interval. The intervals are defined by the timestamps of two consecutive events that come from the sorted list <...
pxaris's user avatar
  • 53
3 votes
1 answer
1k views

Python function to output a string that is justified to the right

I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
pedromartins's user avatar
2 votes
0 answers
56 views

Python: How to best create a dictionary from another dictionary in a library

I have the following code which builds up a dictionary of endpoints that I iterate through later on. Is this the cleanest, most scalable and performant way? I was thinking of adding a list as a key to ...
pee2pee's user avatar
  • 380
0 votes
1 answer
204 views

Convert string to 10 character string with leading zeros if necessary

I have the below data and am obtaining the expected output column for it. ...
banana_99's user avatar
  • 149
1 vote
2 answers
119 views

Search for text in a file

I have this implementation of Grep where I use re.search: ...
Eliaz Bobadilla's user avatar
2 votes
1 answer
105 views

Dose tracker with daily and weekly totals

This is an old script I made a while ago. What it does It tracks your dose of whatever you want tracked (cigarettes, salt, etc), outputs the total for each day, and the full week. What I’m looking for ...
Nickotine's user avatar
  • 378
3 votes
1 answer
820 views

Using Numba works slower than not using it for my Python code

I thought this community is better place to ask my question so I ask here rather than at StackOverflow. Recently, I learned that Numba can make Python function ...
Senna's user avatar
  • 41
1 vote
0 answers
54 views

Asking for feedback, when utilizing Pandas, why is it better to use pandas.Series than lists data type?

I found out the hard way, when utilizing pandas is better to use pandas.Series than lists data type to manipulate data. Even if ...
Alex Ricciardi's user avatar

15 30 50 per page