- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 3
- Posts with Downvotes
- 2
- Downvoting Members
- 3
17 Posted Topics
Re: Here's one toy script I'm going to write when I'm ready: convert a number expressed in decimal digits to a number expressed in a standard way in English words, and vice-versa. (For example, convert 2,733.89 to "two thousand, seven hundred and thirty-three point eight nine" and vice-versa.) | |
Here is a plan for a (relatively) random numeric dictionary I've put together. I'm hoping that people can help me refine the plan so that I can start incremental coding: #! usr/bin/env python # creates a random dictionary from random import randint # user inputs maximum length of dictionary # … | |
"Active cracking" means indirectly changing a plaintext message so that it becomes a totally different, plaintext message that says something totally different but still makes sense, by creating a brand new encryption key that is applied to the ciphertext itself and changes the ciphertext rather than the original plaintext. I … | |
Re: Just as an aside, a way to eliminate duplicates from lists, which the OP asked about: list1 = [1, 2, 7, 3, 9, 2, 3, 5, 1, 0, 9] set1 = {list1[x] for x in len(list1))} list2 = list(set1) # can optionally redefine list1 Although I'm sure that code could … | |
Re: I'm assuming the laptop is 64-bit. Did you choose the 64-bit version of Ubuntu? I've never tried the 32-bit version and don't know if that might be causing the issues with your graphics hardware. | |
The Software Manager offered both python-tk and python3-tk for install, so I installed both. The latter permits me to import tkinter as a whole, while the former does not. Instead, the python 2.x version chopped tkinter up into several submodules that must be imported separately, which is a major nuisance. … | |
Re: I also want to know whether 64-bit is that much of an advantage over 32-bit, considering that my Mint Cinnamon 64-bit kept crashing after install so badly that I had to uninstall it. In my case it was a problem with my PCIE-16 graphics card. | |
Re: def inputt(input_string): while True: outputt = raw_input(input_string): Try: float(outputt) == float(abs(int(outputt))) except ValueError: print("Not a valid number. Please enter a valid number.") else: return float(outputt) def evaluate(miles_driven, gallons_used): return miles_driven / gallons_used miles_driven = inputt("Please input miles driven: ") gallons_used = inputt("Please input gallons used: ") mpg = evaluate(miles_driven, gallons_used) … | |
Re: #! /usr/bin/env python def verify(username, password): if username == "aladdin" and password == "sesane": return True else: return False username = raw_input("Enter username: ") password = raw_input("Enter password: ") result = verify(username, password) if result: pass else: print("Invalid input.") Although it could probably be done much better by a more … | |
This error frustrates me when I want to iterate over the elements of a set, for example when trying to convert the set to a list. How do I get around it? | |
As I've learned more about basic console Python script writing, I've had a look at both Tkinter and GTK+...and, at first glance, I like GTK+ better. Which do you guys prefer, and why? | |
Which of these is the best practice for executable Linux scripts: #! usr/bin/env python #! usr/bin/python #! usr/bin/env python3 #! usr/bin/python3 All four of them work just fine on my system, so I'm looking for the best practice. Thanks. | |
This code: def reverse(x): for i in range(len(x)): y[i] = x[-(i+1)] return y a = [1, 2, 3, 4, 5] b = reverse(a) returns a "global variable 'y' not defined" error. WHAT GLOBAL VARIABLE????? If I add 'y = []' anywhere in the code, either inside the function or outside … | |
I had a function all by itself in the file [filename].py, and the file was properly executable. This is how people advised me to call it externally: import func func.[filename]() But I was getting errors all over the place. So I contacted Python help and they told me something different, … | |
Okay, so cryptography is insanely well developed and I'm not doing anything new here, but I still thought I'd monkey around with a cryptography project. Here's what I want it to do: 1) generate an encryption and decryption key that is randomly between 20 and 40 digits long and contains … | |
Suppose you have this file named func.py: def func(x): y = raw_input(x) return y func(z) And then you have this calling code: z = raw_input('Type a request for input and hit enter: ') omega = execfile('func.py') print(omega) Why does the output always end up being "None?" | |
Re: "Jail function" I love that term! Thanks for a very nice code snippet. |
The End.