Running a C Program from Python

import subprocess
 
cmd = "nameOfCProgram.c"
# Example
# cmd = HelloWorld.c
print ("Hey this is Python Script Running\n")
subprocess.call(["gcc",cmd]) #For Compiling
subprocess.call("./a.out") 
 
#end thats all

The C Code

// DO KEEP BOTH PROGRAMS IN SAME LOCATION
// HelloWorld.c

#include<stdio.h>

int main()
{
printf("Hello World\n");
printf("This C program Running\n");
return 0;
}