15,185 Topics

Member Avatar for
Member Avatar for Sumit_6

A sparse vector is a vector whose entries are almost all zero, like [1, 0, 0, 0, 0, 0, 0, 2, 0]. Storing all those zeros wastes memory and dictionaries are commonly used to keep track of just the nonzero entries. For example, the vector shown earlier can be represented …

Member Avatar for woooee
0
558
Member Avatar for Zeinab_1

Hi there, I have a file with unicode characters I used url decoder code below on a large file, but what is funny is that it doesn't decode some lines,but when I use the code on a file with just that line it decodes it correctly. import urllib.parse for lines …

Member Avatar for Zeinab_1
0
335
Member Avatar for jey1234

I'm not a programmer. I am doing a project for Biology where I will be conducting an experiment on reaction times. Briefly, the subject should click anywhere on the screen as soon as a dot or circle (some graphic) appears on the screen. Details: 1. Program must start at a …

Member Avatar for Tcll
0
1K
Member Avatar for Slass33

I'm doing a multi-line string saved to the variable str: str = """ This is a multiline string """ When I `print str` it works fine. But if I print a different multiline string: ` str = """ This is a multiline string """ print str # Works Fine str_2 …

Member Avatar for megaflo
0
185
Member Avatar for Niloofar24

Hello. This is my code: from bs4 import BeautifulSoup import urllib2 url = urllib2.urlopen('http://www.website_address.com') soup = BeautifulSoup(url) images = soup.find_all('img') Now how can I get the "src" of img tags?

Member Avatar for Gribouillis
0
17K
Member Avatar for DragonMastur

It could be simplifide more, I know. I was doing it as an exersise so its rough and skecthy. But it's workable, I tested it more then 50 times.

Member Avatar for Slass33
0
531
Member Avatar for misgee2001

#I'm begginer for python. I want a program which accept search phrase as raw_input and print search phrase with which document it exists in and line number of the document (file). for example, search phrase is found in file name at line 6. but my program displays 0 and 0 …

Member Avatar for megaflo
0
128
Member Avatar for Slass33

I created a hangman game but it isn't working. The code is here: import random import sys from string import whitespace uy = 'jrekghqegherwgbeuihrweig' choice = 'bhekvvvvvfaktgrwekubfhdbvbvdvbd' z = 'bqhjrfqfbrqkqbg' s = 'ksl' s_space = 'bhks' a4a = 'euwitrigqobehdbfbdjgks' a5a = 'jbfbqwkgnkwqnjg sdn n nmsdafbdjnfbfhskbkjsahjdbhak' a6a = 'qwertyuvdbgshnvdgshgfydss' a7a = …

Member Avatar for Gribouillis
0
305
Member Avatar for vegaseat

This is the updated version of the Tiny Tkinter Calculator. It has more power, since you can type in functions contained in the Python math module then press the equals key. You can then move the result into memory for other calculations. The code is written in OOP class style …

Member Avatar for vegaseat
4
2K
Member Avatar for Zeinab_1

I have wrote a simple code in python s = b'B1=A\xF1adir+al+carrito\n'.decode('latin-1') print(s) with open ('lat.txt','wb') as f: f.write(bytes(s,'latin-1')) the output is **B1=Añadir+al+carrito** and the content of the file is also the same. but when I try to read from a file (with this content B1=A\xF1adir+al+carrito ) for lines in open('mytxt1.txt','rb'): …

Member Avatar for vegaseat
0
265
Member Avatar for Saran_1

I have the CSV with the following column headers: "G","Association","Subset","Rank","First Name","Last Name","Middle Name","Date of Birth","SS","Drivers License Number","Address","Phone Number","A","CF","CM","I","F","J","CN","I","CN" The Output XML format is what I seek: <GIs> <GIR> <G></G> <GM> <FirstName></FirstName> <LastName></LastName> <MiddleName></MiddleName> <FullName></FullName> <DateofBirth></DateofBirth> <SS></SS> <DriversLicenseNumber></DriversLicenseNumber> <Address> <AddressText></AddressText> <Latitude></Latitude> <Longitude></Longitude> </Address> <PhoneNumber></PhoneNumber> <A></A> <CF></CF> <CM></CM> <Association></Association> <Subset></Subset> <Rank></Rank> <I></I> …

0
111
Member Avatar for Atul_4

Hi is here any one who can tell me that how can i generate the licence key or any other things for securing my client server program please help me

Member Avatar for snippsat
0
653
Member Avatar for vegaseat

The example shows how to establish a dictionary of (row, column):value pairs to mimic a two dimensional array. This can be easily expanded to more dimensions. Python3 has dictionary comprehension, making the process of creating a dictionary of this type easier.

Member Avatar for vegaseat
1
7K
Member Avatar for DragonMastur

I would like the widgets on the window to expand as you expand the window. I know you can do it with the pack method but I'm using the grid method to arange my widgets. Pack Method: label = Label(root, text="Some Text") label.pack(expand=1, fill=BOTH) Grid Method I'm using: self.inventoryLabel = …

Member Avatar for woooee
0
6K
Member Avatar for vegaseat

The idea of this thread is to help the beginning Python programmer with hints and helpful code. Please feel free to contribute! If you have any questions start your own thread! The creators of Python are very active, improving the language all the time. Here is a little of the …

Member Avatar for vegaseat
23
34K
Member Avatar for vegaseat

Just a simple password creator using Python code. The length of the password can be set and the characterset could be changed if you so desire.

0
572
Member Avatar for sbaw

Hi I am currently using pyinstaller 2.1 with python 2.7. I am making modifications to "TI's MSP430 Tools (Python scripts and library)" which allows the update of the MSP430 firmware over USB. Specifically, I have made some modifications to the top-level script and when I run the script it works …

Member Avatar for megaflo
0
1K
Member Avatar for BustACode

Note: In Python 2.7 use: `from __future__ import print_function` to use examples. In Python, by default, the key and value pairs in a dictionary are stored as hashes, therefore dictionaries do not retain the order in which values were added, and cannot be ordered. v_Dict ={} v_Dict["First"] = 99 v_Dict["Second"] …

Member Avatar for DragonMastur
1
479
Member Avatar for DragonMastur

I needed a calculator and I didn't want to use google since my internet is slow. So I made one! Here it is. Working with it is simple. Use the number and operation keys("c" for clear, "p" for pi, and "s" for sqrt) as well as the return and enter …

0
692
Member Avatar for vegaseat

After you got the basics of Python under your belt, the best way to get a good knowledge of the language and improve your coding skills is to start on a project you are interested in. Maybe an image viewer, a slide show, computer generated random or fractal art, a …

Member Avatar for vegaseat
20
18K
Member Avatar for Brandon500

Hello everybody I'm doing a program that finds the nth number in the fibonacci sequence. I actually already coded it. What I would like someone to do is maybe you could help me code it another way. The reason is the last assignment I turned in got a zero, because …

Member Avatar for woooee
0
233
Member Avatar for getanshub4u

Any good beginner books on python? I want to learn python easy and fast.I have coded some basic programs in c,c++,Java. Wanna learn python for scripting in linux.

Member Avatar for dewhales
0
442
Member Avatar for DragonMastur

karmstrong ask in the Python chat if any one was farmilar with converting a for loop in C to Python. Here is a program in python that will do it for you! Thank You!

Member Avatar for vegaseat
0
815
Member Avatar for vegaseat

This is a test to get the Python snippets going! For those of you who are scared of snakes, the language is named after the TV program, not the snake. Python is an interpreted language, but programs to compile/combine the code to an exe file are available (Py2Exe). The latest …

Member Avatar for vegaseat
2
3K
Member Avatar for Niloofar24

Hello. There is a text in my Python script that is in Persian language and the letters are from left to right, but in Persian language letters should be written from right to left. What should i do now to fix it and print it in UTF-8 format?

Member Avatar for megaflo
0
392
Member Avatar for anumash

Hello, I am starting out learning Python syntax and in the book that I am reading it is mentioned that objects are assigned by reference and not by value, i.e. foo1=4 foo2=foo1 Now foo2 and foo1 refer to the same object in memory and I even verified this by using …

Member Avatar for megaflo
0
331
Member Avatar for halo_123

1)Create a list of the odd numbers between 1 and n (include 1 as well as n -- if it's odd-- in the list). Associate the list with the variable odds . 2)Given the list my_list containing integers, create a list consisting of all the even elements of my_list . …

Member Avatar for PartVIII
-11
2K
Member Avatar for Rajesh_18

Dear All, I have learned to use the shutil.move to move files from one folder to another but I need to also do the following . Would appreicate any help. Perhaps a template so I can fill the gaps and learn along the way. I have a folder with sub …

Member Avatar for Gribouillis
0
279
Member Avatar for DragonMastur

I made a little py editor because I didn't want to go to all the troble of installing an idle, but I didn't like notepad either. Here it is!

Member Avatar for DragonMastur
3
316
Member Avatar for Brandon500

Hello everyone I'm having trouble with this program in Python called sumList(nums). I already tried to program it, but I get the incorrect output. The program is suppose to get the summ of numbers entered into a list by the user. Mine does not return the sum just the first …

Member Avatar for BustACode
1
1K

The End.