Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to multiply a list by an integer?

This is so basic I'm embarrassed to even ask the question, but I've tried all the possibilities I can think of, and searched two SM guides (SM Tutorial and SM for Undergrads), and I can't find out how to do this. I want to multiply a list of rational numbers (fractions) by an integer. I've tried with lists and sets (although sets wouldn't really work, because the list of fractions contains repetitions), and I've tried with the single integer as simply a number and as a list. But I always get an error message, saying "unsupported operand type(s)" or something similar. Here is an example of what I'm trying to do:

a = [1, 1/2, 1/3, 3/8, 1/5, 1/3, 3/14, 1/4, 1/6, 1/4,]

b = 840

print (a ^ b)

Help for a clueless newbie would be greatly appreciated. (Also, if anyone can recommend a tutorial or guide that will explain how to do these sort of things in SM, that would be even better!)

How to multiply a list by an integer?

This is so basic I'm embarrassed to even ask the question, but I've tried all the possibilities I can think of, and searched two SM guides (SM Tutorial and SM for Undergrads), and I can't find out how to do this. I want to multiply a list of rational numbers (fractions) by an integer. I've tried with lists and sets (although sets wouldn't really work, because the list of fractions contains repetitions), and I've tried with the single integer as simply a number and as a list. But I always get an error message, saying "unsupported operand type(s)" or something similar. Here is an example of what I'm trying to do:

a = [1, 1/2, 1/3, 3/8, 1/5, 1/3, 3/14, 1/4, 1/6, 1/4,]

b = 840

print (a ^ b)

Help for a clueless newbie would be greatly appreciated. (Also, if anyone can recommend a tutorial or guide that will explain how to do these sort sorts of things in SM, that would be even better!)