LinuxQuestions.org
Help answer threads with 0 replies.
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 02-14-2020, 11:46 PM   #1
shravan1234
LQ Newbie
 
Registered: Jan 2020
Posts: 3

Rep: Reputation: Disabled
Please help me in writing python code which i have already written in c


I have written c program which is working correctly and i am getting exact output but i need to write the same program in python script which i am feeling difficult to write so please help me in writing the same c program in python. I am posting the program which i have already written in c language.
Attached Files
File Type: txt TA_Converge_program.txt (3.8 KB, 26 views)
 
Old 02-15-2020, 12:04 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 8,455
Blog Entries: 13

Rep: Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773Reputation: 3773
Perhaps you've started your python program?

Please post what you have of it.
 
Old 02-15-2020, 12:13 AM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,405

Rep: Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563Reputation: 1563
Yes. You need to show is where you’re stuck in python, please.
 
Old 02-15-2020, 11:56 AM   #4
boughtonp
Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 255

Rep: Reputation: 147Reputation: 147
Why? What is the larger problem you're trying to solve by doing this?

i.e. You already have working code, why does it need to be in Python?

As others have said: you need to show your existing efforts. Last month you asked about dealing with JSON in Python, so you presumably have some degree of Python knowledge/ability by now? None of the C code you've posted looks particularly complex, so you need to clarify what part you need help translating, instead of just asking for complete code.

If you show effort and ask for help when you're stuck, you'll get it - but there's a difference between that and asking people to do free work for you.

 
1 members found this post helpful.
Old 02-15-2020, 01:42 PM   #5
teckk
Senior Member
 
Registered: Oct 2004
Distribution: FreeBSD Arch
Posts: 2,622

Rep: Reputation: 645Reputation: 645Reputation: 645Reputation: 645Reputation: 645Reputation: 645
To get you started.
Code:
int main()
{
    FILE *fpi3005Hex = fopen("f3005_Hex.dat", "r");
    FILE *fpi3005Dec = fopen("f3005_Dec.dat", "r");
    FILE *fpo3005 = fopen("f3005.dat", "w");


    printf("File open completed\n ");

    if((fpi3005Hex != NULL) && (fpi3005Dec != NULL) && (fpo3005 != NULL))
    {
Code:
>>> import os
>>> open('f3005_Hex.dat', 'a').close()
>>> with open('f3005_Hex.dat', 'r') as f:
...     print('File open completed')
... 
File open completed
>>> if os.stat('f3005_Hex.dat').st_size == 0:
...     print('File size 0')
... else:
...     print('File size not 0')
... 
File size 0
 
Old 02-16-2020, 09:15 PM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_12{.0|.1}
Posts: 5,357
Blog Entries: 11

Rep: Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323Reputation: 3323
@shravan1234: I see that you have apparently posted replies to this thread, but used the Report button instead of Quote or Post Reply. Please try again to post those correctly.

Again, you are still incorrectly using the Report button to post replies, as a result they are not visible to others in the thread.

Please use the Quote button to reply to another post, or use the Post Reply button at top or bottom of each thread page. Please do not reply using the Report button.

Last edited by astrogeek; 02-16-2020 at 10:00 PM.
 
1 members found this post helpful.
  


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
[SOLVED] alsa-oss and slack and programming to use it in code already written. e16 BW-userx Slackware 2 12-08-2018 07:17 PM
[SOLVED] on gcc compiler, i have a source code which has obect file i.e., .o file already generated need to generate executable in .bin format help. javedalam Linux - Embedded & Single-board computer 1 10-12-2018 06:33 AM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 09:30 PM
Has someone already written a tutorial script? kedens Linux - General 1 10-10-2006 09:44 PM
Some C code that I have written wampire Programming 1 04-29-2006 08:30 PM

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

All times are GMT -5. The time now is 04:35 PM.

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