c to python code converter

import sys

def mergesort_2ndstep(l, r):
	len_l = len(l)
	len_r = len(r)
	# initializing a list of length zero
	sorted_array = []
	i,j = 0,0
	while i < len_l:
		num1 = l[i]
		for x in range(j,len_r):
			num2 = r[x]
			if num2 < num1 :
				sorted_array.append(num2)
				j += 1
		
		sorted_array.append(num1)
		i += 1

	if len(sorted_array) != len_l + len_r:
		# Checking extreme conditions
		sorted_array[i+j:] = r[j:]
	return sorted_array


def mergesort_1ststep(L,start,stop):
	# a list can be divided into two 
	# if length of list is atleast two
	if stop - start > 1:
		l = mergesort_1ststep(L,start,start + (stop-start)//2)
		r = mergesort_1ststep(L,start + (stop-start)//2,stop)
		# mergeing two lists(sorting the l and r parts)
		L[start:stop] = mergesort_2ndstep(l,r)
	return L[start:stop]

# START
List_of_nums = []
file_to_open = "input1.txt"

try:
	read_file = open(file_to_open,"r")
	write_file = open("sameeraz.txt","w")
	if read_file != None:
		# appending every num from file to list_of_nums
		for line in read_file:
			line = int(line)
			List_of_nums.append(line)
		# applying mergesort
		mergesort_1ststep(List_of_nums,0, len(List_of_nums))
		# writing to an output file
		# excluding the last element 
		k = List_of_nums.pop()
		for num in List_of_nums:
			write_file.write(f"{num}\n")
		# writing last element without next line
		write_file.write(f"{k}")
	
		read_file.close()
		write_file.close()
except:
	print("file not found")

3.78
9
Msciwoj 95 points

                                    #include &lt;stdio.h&gt;
 
int main()
{

	char name [20] = &quot;Lakshmisprasad&quot;;
	char email [40]=&quot;[email protected]&quot;;
	char slack[10]=&quot;@lakshmip&quot;;
	char twitter[20]=&quot;Lakshmip2798&quot;;
	char biostack [20]=&quot;Functional Genomics&quot;;

	printf(&quot;name:%s\nemail:%s\ntwitter:%s\nbiostack:%s\nslack:%s\n&quot;,name,email,twitter,biostack, slack	);
	return 0;
}
 

3.78 (9 Votes)
0
3.9
12
Xoxocrow 155 points

                                    #include&lt;iostream&gt;
// Defining MAX size to 10
#define MAX 10

using namespace std;

typedef struct Edge
{
  int source;
  int destination;
  int weight;
}Edge;

void bellman_ford_algo(int nodevertex,Edge edge[],int source_graph,int nodeedge)
{
  int u,v,weight,i,j=0;
  int distance[MAX];

  for(i=0;i&lt;nodevertex;i++)
  {
    distance[i]=999;
  }

  // distance of source vertex
  distance[source_graph]=0;

  // free all the edges nodevertex - 1 times
  for(i=0;i&lt;nodevertex-1;i++)
  {
    for(j=0;j&lt;nodeedge;j++)
    {
      u=edge[j].source;
      v=edge[j].destination;
      weight=edge[j].weight;


      if(distance[u]!=999 &amp;&amp; distance[u]+weight &lt; distance[v])
      {
        distance[v]=distance[u]+weight;
      }
    }

  }

  // checking for negative cycle
  for(j=0;j&lt;nodeedge;j++)
  {
    u=edge[j].source;
    v=edge[j].destination;
    weight=edge[j].weight;

    if(distance[u]+weight &lt; distance[v])
    {
      cout&lt;&lt;&quot;\n\nNegative Cycle present..!!\n&quot;;
      return;
    }
  }

  cout&lt;&lt;&quot;\nVertex&quot;&lt;&lt;&quot;  Distance from source&quot;;
  for(i=1;i&lt;=nodevertex;i++)
  {
    cout&lt;&lt;&quot;\n&quot;&lt;&lt;i&lt;&lt;&quot;\t&quot;&lt;&lt;distance[i];
  }

}


int main()
{
  int nodevertex,nodeedge,source_graph;
  Edge edge[MAX];

  cout&lt;&lt;&quot;Enter the number of vertices you want : &quot;;
  cin&gt;&gt;nodevertex;


  printf(&quot;Enter the source vertex of the graph: &quot;);
  cin&gt;&gt;source_graph;

  cout&lt;&lt;&quot;\nEnter no. of edges you want : &quot;;
  cin&gt;&gt;nodeedge;

  for(int i=0;i&lt;nodeedge;i++)
  {
    cout&lt;&lt;&quot;\nEdge Number &quot;&lt;&lt;i+1&lt;&lt;&quot;=&quot;;
    cout&lt;&lt;&quot;\nEnter source vertex here :&quot;;
    cin&gt;&gt;edge[i].source;
    cout&lt;&lt;&quot;Enter destination vertex here:&quot;;
    cin&gt;&gt;edge[i].destination;
    cout&lt;&lt;&quot;Enter weight here :&quot;;
    cin&gt;&gt;edge[i].weight;
  }

  bellman_ford_algo(nodevertex,edge,source_graph,nodeedge);

  return 0;
}

3.9 (10 Votes)
0
4
4

                                    np.linspace(0,1,11)

4 (4 Votes)
0
3.4
5
Bizhan 135 points

                                    def main():
  # 4 x 4 csr matrix
  #    [1, 0, 0, 0],
  #    [2, 0, 3, 0],
  #    [0, 0, 0, 0],
  #    [0, 4, 0, 0],
  csr_values = [2, 3, 1, 4,5]
  col_idx    = [1, 2, 0, 1,1]
  row_ptr    = [0, 2, 4,5]
  csr_matrix = [
      csr_values,
      col_idx,
      row_ptr
      ]

  dense_matrix = [
      [0, 3, 0],
      [1, 4, 5],
      [2, 0, 0],
      ]

  res = [
      [0, 0, 0],
      [0, 0, 0],
      [0, 0, 0],
      ]

  # matrix order, assumes both matrices are square
  n = len(dense_matrix)

  # res = dense X csr
  csr_row = 0 # Current row in CSR matrix
  for i in range(n):
    start, end = row_ptr[i], row_ptr[i + 1]
    for j in range(start, end):
      col, csr_value = col_idx[j], csr_values[j]
      for k in range(n):
        dense_value = dense_matrix[k][csr_row]
        res[k][col] += csr_value * dense_value
    csr_row += 1

  print(res) 


if __name__ == '__main__':
  main()

3.4 (5 Votes)
0
3.8
10
Krupashanker 105 points

                                    #include &lt;stdio.h&gt;


int main()
{
    int n,np=0,i,j,flag=0;
    scanf(&quot;%d&quot;,&amp;n);
        for(i=2;i&lt;=n;i++)
            {
                for(j=1,flag=0;j&lt;=i;j++)
                {
                 if(i%j==0)
                 flag++;
                }

        if(flag==2)
            np++;
            }

int total=n-2+1;

 for(i=total/2;i&gt;=1;i--)
if(total%i==0&amp;&amp;np%i==0)
   {
       total/=i;
        np/=i;
   }
   printf(&quot;%d/%d&quot;,np,total);
    return 0;
}

3.8 (10 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
online python to c converter how to convert python to C online code python to c converter python to c transpiler online python compiler to c cpython convert python to c online code converter python to c online convertion tool c language to python converter turning python into c convert c code into python code python to c convertor online does python convert to c c to python translator how to convert c program to python online how to convert c program to python python to c converter tool python to c online converter convert c into python convert c code in python python code to c code converter online online pythoon to c convertor convert python to c online free python to c online&acute; convert python script to c online convert python to c online tool free python to c converter online free python to C online python convert to c convert python program to C program convert code from python to c convert c code to python online free Tool to convert C code to Python online c to python converter online free covert python to c code convert python language to c online convert c language to python online convert python to c language c code convert to python online convert python code to c c into python c converter to python c program converter to python program convert c++ to python online python to c code conversion convert python code into c online convert python code into c turn python into c convert python to c online covert pyton to c Python to C converter tool online c convert python from c to python online c to python converter online c code to python code conversion convert c code to python compiler online converter from c to python how to convert c code to python python to c code convertor convert c program to python C to python c convert to python c code to python code converter converte python to c how to convert c code in python c code to python code converter online Python c conversion python to c convertor python convert to c code convert c to python c to python converter c to python c to python converter code converter python to c convert python code to c code c to python code converter online c code to python converter online c to python code converter convert python code to c code online python to c code converter covert python code to C online code converter c to python convert c code to python online c to python converter online convert c code to python convert simple python code to c convert c program to python online python to c program converter convert c to python online CONVERT PYTHON TO C convert python to c code python to c converter online Can I convert Python code to C python to c converter program converter from python to c convert python into c python to c converter ONLINE python to c code converter online code converter python to convert python code to c online free python code to c code converter convert python code to c online code converter python to c online python code to c convert python to c++ online convert python code to c online
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source