LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-13-2018, 09:16 AM   #1
zak100
Member
 
Registered: Jul 2009
Posts: 262

Rep: Reputation: 2
Windows: How to print two columns of a table in python?


Hi,
I got a small prog from a book. I want to print two columns of table. But its printing in a row-wise.
Can some body guide me how to use table command to print each of its columns with headings.
Code:
 
Cdegrees = range(-20, 41, 5) # -20, -15, ..., 35, 40
Fdegrees = [(9.0/5)*C + 32 for C in Cdegrees]
table = [Cdegrees, Fdegrees]
print (table)
I am getting following output:
Quote:
>python table1.py
[range(-20, 41, 5), [-4.0, 5.0, 14.0, 23.0, 32.0, 41.0, 50.0, 59.0, 68.0, 77.0, 86.0, 95.0, 104.0]]

>
Zulfi.
 
Old 07-13-2018, 09:40 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,277

Rep: Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903
Quote:
Originally Posted by zak100 View Post
Hi,
I got a small prog from a book. I want to print two columns of table. But its printing in a row-wise. Can some body guide me how to use table command to print each of its columns with headings.
Code:
 Cdegrees = range(-20, 41, 5) # -20, -15, ..., 35, 40
Fdegrees = [(9.0/5)*C + 32 for C in Cdegrees]
table = [Cdegrees, Fdegrees]
print (table)
I am getting following output:
Code:
>python table1.py
[range(-20, 41, 5), [-4.0, 5.0, 14.0, 23.0, 32.0, 41.0, 50.0, 59.0, 68.0, 77.0, 86.0, 95.0, 104.0]]
Probably a good idea to consult that book, then. You've posted a VERY small bit of the program, and we only know it's python because of the output you posted.

We will again 'guide you' to do some research on your own, as you've been asked to numerous times over the years. Putting "python print table" into Google pulls up over 32 MILLION hits, with samples. Again, after eleven years, you should be able to do some simple things...especially since you claim to be a teacher of these subjects:
https://www.linuxquestions.org/quest...tp-4175524921/
https://www.linuxquestions.org/quest...ld-4175632000/

Reference the many Google hits, see the examples. Past that, post the code that YOU have written, and tell us where you're stuck, but please don't post something you copied/pasted from somewhere, and just ask us to debug/change/explain it.
 
1 members found this post helpful.
Old 07-13-2018, 11:15 AM   #3
zak100
Member
 
Registered: Jul 2009
Posts: 262

Original Poster
Rep: Reputation: 2
You should learn first. Dont forget that you are a fake and you must not because you have been declared fake thrice. If you dont know the answer dont reply. I would ask the forum administrator to reset your points to zero so that you should start learning.

Zulfi.
 
Old 07-13-2018, 11:33 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,277

Rep: Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903
Quote:
Originally Posted by zak100 View Post
You should learn first. Dont forget that you are a fake and you must not because you have been declared fake thrice. If you dont know the answer dont reply. I would ask the forum administrator to reset your points to zero so that you should start learning.
And you're still making no sense. No clue what you're going on about with 'you are fake' and 'reset your points to zero'.

You were asked to POST THE CODE; you did not. You were given a search term that gives you LOTS of examples; and you apparently won't look it up. There could very well be people here that COULD help you, but since you don't provide the code, what do you think we can tell you???? Nothing anyone can do to help you if you don't cooperate, and show some actual effort. You've been asked about this for YEARS at this point.

Last edited by TB0ne; 07-13-2018 at 11:35 AM.
 
1 members found this post helpful.
Old 07-13-2018, 12:48 PM   #5
zak100
Member
 
Registered: Jul 2009
Posts: 262

Original Poster
Rep: Reputation: 2
Hi and congratulations to everybody on this forum because this is the fourth time that I have caught you as a fake man.
<You were asked to POST THE CODE;>
Completely wrong. I new that you dont have the capabilities and then you fabricated a story and even you went beyond this and tried to shatter this forum. At that time I dont have any choice but to post the code and you failed. But i did not declare you fake. After that I showed you the steps and you went directly to step 6 without going through the steps 1-5 which is again an indication that you are a fake man. But I did not declare you fake. Then you again proved that you are a fake in this particular thread. I again dont want to declare you a fake because this would be the 4th time that you would be fake and your chance of preventing a reset is almost null . But I did not declare you fake even though I realized that you are a hurdle in the progress of this forum. I was creating new openings and because you are a fake you dont like it. But i did not declare you fake. But then you yourself declared yourself a fake man by saying:
"we only know it's python because of the output you posted. "
even though this sentence was wrong. It should be:
"I only know it's python because of the output you posted. "

This is a shame for a over saturated poster but not for a fake man. That's why I declared you a fake man 4th time.

Tell me how many languages dont use semi colon as a statement terminator? You dont know because you are a fake ....

You are caught 4th time but I wont stop here because I would continue this as much as possible. Because you are the greatest fake person of human race.

Zulfi.
 
Old 07-13-2018, 06:31 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,277

Rep: Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903
Quote:
Originally Posted by zak100 View Post
Hi and congratulations to everybody on this forum because this is the fourth time that I have caught you as a fake man.
Still absolutely NO CLUE as to what you mean.
Quote:
<You were asked to POST THE CODE;>
Completely wrong. I new that you dont have the capabilities and then you fabricated a story and even you went beyond this and tried to shatter this forum. At that time I dont have any choice but to post the code and you failed. But i did not declare you fake. After that I showed you the steps and you went directly to step 6 without going through the steps 1-5 which is again an indication that you are a fake man. But I did not declare you fake. Then you again proved that you are a fake in this particular thread. I again dont want to declare you a fake because this would be the 4th time that you would be fake and your chance of preventing a reset is almost null . But I did not declare you fake even though I realized that you are a hurdle in the progress of this forum. I was creating new openings and because you are a fake you dont like it. But i did not declare you fake.
Sorry, still nothing. You were asked here to post the entire program. You did not. You still won't. Yet you seem to want to invent reasons as to why everyone should help you, and declare everyone else 'fake' (whatever that means), and show no effort of your own.
Quote:
But then you yourself declared yourself a fake man by saying:
"we only know it's python because of the output you posted. "
even though this sentence was wrong. It should be:
"I only know it's python because of the output you posted. "
Nope...the 'we' is EVERYONE HERE who reads this post. That's the 'we'..do you understand?? Probably best not to try to correct someones English, when you seem to have trouble with it yourself. Again, we know it's python, because you posted the output that starts with "python ...." understand???
Quote:
This is a shame for a over saturated poster but not for a fake man. That's why I declared you a fake man 4th time. Tell me how many languages dont use semi colon as a statement terminator? You dont know because you are a fake .... You are caught 4th time but I wont stop here because I would continue this as much as possible. Because you are the greatest fake person of human race.
If you say so. And you are still showing no effort, not answering questions, and this is something you've done from your very first post here. Anyone can look at your behavior. Feel free to 'declare me to be fake' as many times as you'd like. No idea what you mean by 'steps 1-5, 6', etc.

Last edited by TB0ne; 07-14-2018 at 08:25 AM.
 
1 members found this post helpful.
Old 07-18-2018, 03:35 PM   #7
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 1,963

Rep: Reputation: 301Reputation: 301Reputation: 301Reputation: 301
Quote:
I want to print two columns of table.
I'll give you some examples for your numbers. (python3)
Code:
>>> for x in range(-20, 41, 5):
...     print ((x), (x * (9/5) + 32))
... 
-20 -4.0
-15 5.0
-10 14.0
-5 23.0
0 32.0
5 41.0
10 50.0
15 59.0
20 68.0
25 77.0
30 86.0
35 95.0
40 104.0
Code:
>>> var1 = range(-20, 41, 5)
>>> var2 = [(9.0/5) * C + 32 for C in var1]
>>> for x in (list(var1)):
...     print ((x), (x * (9/5) + 32))
... 
-20 -4.0
-15 5.0
-10 14.0
-5 23.0
0 32.0
5 41.0
10 50.0
15 59.0
20 68.0
25 77.0
30 86.0
35 95.0
40 104.0
Quote:
I got a small prog from a book.
You are going to have to understand python a little better before you continue. Read the docs, that's what the rest of us do.

https://docs.python.org/
https://docs.python.org/3/tutorial/index.html
 
Old 07-18-2018, 11:26 PM   #8
zak100
Member
 
Registered: Jul 2009
Posts: 262

Original Poster
Rep: Reputation: 2
Hi,

Thanks for your response. Actually I didnt like the over saturated poster when he said to search Google. This is wrong that he is promoting Google on this forum. This also indicates that he cant write even a simple 'print' statement.

God bless you people.

Zulfi.
 
Old Yesterday, 06:04 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 20,277

Rep: Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903Reputation: 4903
Quote:
Originally Posted by zak100 View Post
Hi,
Thanks for your response. Actually I didnt like the over saturated poster when he said to search Google. This is wrong that he is promoting Google on this forum. This also indicates that he cant write even a simple 'print' statement.
You can use whatever search engine you want to. Fact is, Python has modules to allow it to print tables....which you didn't look up, even though you were handed a term to search on. One of the first hits: https://gist.github.com/jhcepas/5884168 And *YOU* seemed to have no problem using Google before, when you said you used it:
https://www.linuxquestions.org/quest...hm-4175624903/

...in another of your Python threads from a while back. Where you apparently couldn't even do your own searches, and asked people HERE to do it for you. And what about your other Python related threads?
https://www.linuxquestions.org/quest...la-4175631338/
https://www.linuxquestions.org/quest...py-4175631382/
https://www.linuxquestions.org/quest...on-4175631988/

And when teckk tells you to read the docs, it's somehow ok?

**TECKK** see the OP's posting history. He's been directed to docs, searches, and samples many times.

If you don't like people telling you to search, then you should actually do it yourself. Again you need to read the "Question Guidelines" and the LQ Rules. You repeatedly ask for handouts, and have YET to show the code that you wrote, samples of your input data, or how you want it output, despite being asked numerous times. I can easily write a print statement in MANY languages...but I won't do your homework/work for you, nor will anyone else. You typed in a program from a book, and couldn't make it work??? And you're a teacher with eleven years of experience??

Last edited by TB0ne; Yesterday at 09:00 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Open.Office. is it possible to put columns inside cells of a table? 1sweetwater! Linux - Software 1 01-12-2015 05:29 PM
Why does open office table only show 16 of 21 columns in table format columns? 1sweetwater! Linux - Software 1 12-03-2014 01:19 PM
Format results into table that have columns and rows ModServ Linux - General 11 01-18-2012 06:41 AM
OO Writer: two columns in my table are read-only newbiesforever Linux - Software 1 10-14-2009 07:06 PM
shell script/command for converting columns/table onto a single line skuz_ball Programming 9 11-30-2007 03:02 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration