Sage Range function
I use sage range function to print numbers form 1 to say 10 using print [1..10]. How to print only even numbers using this?
asked 7 years ago
This post is a wiki. Anyone with karma >750 is welcome to improve it.
I use sage range function to print numbers form 1 to say 10 using print [1..10]. How to print only even numbers using this?
using list comprehension:
sage: [i for i in [1..10] if i%2==0]
[2, 4, 6, 8, 10]
see more alternatives in the Programming in Python and Sage Thematic Tutorial.
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 7 years ago
Seen: 3,723 times
Last updated: Sep 17 '17
Limiting the display range of a 3d plot
Getting range from things which aren't integers yet, but will be
Problem getting indices to sync up
Define range of y axis, instead of just x axis?
Determine domain and range of linear equation?
Sage ranges in IP-Notebooks on CSM
Is the following ok?
I knew that. I was wondering if same can be done with [1..10]?