Q:

Python 3.5.0 - TypeError: can't multiply sequence by non-int of type 'float'

I can't make this to work.
I've tried:
print('Names choosed was %s' % (random.sample(namesList, float(len(namesList))*0.25))), but still doesn't work.

Tried to seek other solutions, but still can't solve this.
import random

f= open('file.txt','r')
namesList = []

for line in f:
    namesList.append(line.strip())

print('There are %d names in list and we will choose %.0f from the list.' % (len(namesList), float(len(namesList))*0.25))

print('Names choosed was %s' % (random.sample(namesList, len(namesList)*0.25)))

f.close()

A:

Floating point is the devil, just divide:
print('Names choosed was %s' % (random.sample(namesList, len(namesList) // 4),))

If you need to convert from a non-fixed float to a rough int divisor, one approach would be to divide 1 by the float to get the inverse, then convert to int (with int constructor, or round or whatever you like), e.g.:
divisor = int(1 / floatval)
print('Names choosed was %s' % (random.sample(namesList, len(namesList) // divisor),))

