convert python code to c online
''' Program for identify the Bulk density, Particle density, Percent pore space in python (pore space cylinder method)'''
#Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100 #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)
4
6
ALGORITMO
DECLARE num[5,4] NUMÉRICO
num_aux, i, j, k, l, m, n, lin, col NUMÉRICO
PARA i ← 1 ATÉ 5 FAÇA
INÍCIO
PARA j ← 1 ATÉ 4 FAÇA
INÍCIO
LEIA num_aux
IF i = 1 E j = 1
ENTÃO num[i, j] ← num_aux
SENÃO INICIO
k ← 1
l ← 1
ENQUANTO num[k, l] < num_aux E (k i OU l j) FAÇA
INÍCIO
l ← l + 1
SE l > 4
ENTÃO INÍCIO
k ← k + 1
l ← 1
FIM
FIM
m ← i;
n ← j;
ENQUANTO m k OU n l FAÇA
INÍCIO
SE n-1 < 1 ENTÃO
INÍCIO
lin ← m-1
col ← 4
FIM
SENÃO INÍCIO
lin ← m
col ← n-1
FIM
num[m][n] ← num[lin][col]
n ← n-1
SE n < 1
ENTÃO INÍCIO
n ← 4
m ← m-1
FIM
FIM
num[k][l] ← num_aux
FIM
FIM
FIM
PARA i ← 1 ATÉ 5 FAÇA
INÍCIO
PARA j ← 1 ATÉ 4 FAÇA
INÍCIO
ESCREVA “Elemento da posição “, i, “-”, j, “ = “, num[i][j]
FIM
FIM
FIM_ALGORITMO.
Thank you!
6
0
3.5
2
option=int(input('Press 1 for generating hamming code \nPress 2 for finding error in hamming code\n\t Enter your choice:--\n'))
if(option==1): # GENERATE HAMMING CODE
print('Enter the data bits')
d=input()
data=list(d)
data.reverse()
c,ch,j,r,h=0,0,0,0,[]
while ((len(d)+r+1)>(pow(2,r))):
r=r+1
for i in range(0,(r+len(data))):
p=(2**c)
if(p==(i+1)):
h.append(0)
c=c+1
else:
h.append(int(data[j]))
j=j+1
for parity in range(0,(len(h))):
ph=(2**ch)
if(ph==(parity+1)):
startIndex=ph-1
i=startIndex
toXor=[]
while(i<len(h)):
block=h[i:i+ph]
toXor.extend(block)
i+=2*ph
for z in range(1,len(toXor)):
h[startIndex]=h[startIndex]^toXor[z]
ch+=1
h.reverse()
print('Hamming code generated would be:- ', end="")
print(int(''.join(map(str, h))))
elif(option==2): # DETECT ERROR IN RECEIVED HAMMING CODE
print('Enter the hamming code received')
d=input()
data=list(d)
data.reverse()
c,ch,j,r,error,h,parity_list,h_copy=0,0,0,0,0,[],[],[]
for k in range(0,len(data)):
p=(2**c)
h.append(int(data[k]))
h_copy.append(data[k])
if(p==(k+1)):
c=c+1
for parity in range(0,(len(h))):
ph=(2**ch)
if(ph==(parity+1)):
startIndex=ph-1
i=startIndex
toXor=[]
while(i<len(h)):
block=h[i:i+ph]
toXor.extend(block)
i+=2*ph
for z in range(1,len(toXor)):
h[startIndex]=h[startIndex]^toXor[z]
parity_list.append(h[parity])
ch+=1
parity_list.reverse()
error=sum(int(parity_list) * (2 ** i) for i, parity_list in enumerate(parity_list[::-1]))
if((error)==0):
print('There is no error in the hamming code received')
elif((error)>=len(h_copy)):
print('Error cannot be detected')
else:
print('Error is in',error,'bit')
if(h_copy[error-1]=='0'):
h_copy[error-1]='1'
elif(h_copy[error-1]=='1'):
h_copy[error-1]='0'
print('After correction hamming code is:- ')
h_copy.reverse()
print(int(''.join(map(str, h_copy))))
else:
print('Option entered does not exist')
Thank you!
2
0
3.83
6
# Raw Package
import numpy as np
import pandas as pd
#Data Source
import yfinance as yf
#Data viz
import plotly.graph_objs as go
#Interval required 1 minute
data = yf.download(tickers='UBER', period='1d', interval='1m')
#declare figure
fig = go.Figure()
#Candlestick
fig.add_trace(go.Candlestick(x=data.index,
open=data['Open'],
high=data['High'],
low=data['Low'],
close=data['Close'], name = 'market data'))
# Add titles
fig.update_layout(
title='Uber live share price evolution',
yaxis_title='Stock Price (USD per Shares)')
# X-Axes
fig.update_xaxes(
rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=15, label="15m", step="minute", stepmode="backward"),
dict(count=45, label="45m", step="minute", stepmode="backward"),
dict(count=1, label="HTD", step="hour", stepmode="todate"),
dict(count=3, label="3h", step="hour", stepmode="backward"),
dict(step="all")
])
)
)
#Show
fig.show()
Thank you!
6
0
3.8
10
importmath #Get the inputs via user interaction with help of variables Na ,Ca ,Mg
Na=input ('Enter the value of Na+:')
Ca=input ('Enter the value of Ca2:')
Mg=input ('Enter the value of Mg2+:')#Calculation based on the formula
sar=float(Na)/(math.sqrt((float(Ca)+float(Mg))/2))
#Print the SAR
print("SAR:",sar)#Control flow statement for remarks
if sar>=0and sar<=10:
print("water class=s1 Low sodium hazard Remarks: Little or no hazard")
elif sar>=10and sar<=18:
print("water class=s2 Medium sodium hazard Remarks: Appreciable hazard but can be used with appropriate management techniques")
elif sar>=18and sar<=26:
print("water class=s3 high sodium hazard Remarks: Unsatisfactory for most of the crops")
elif sar>=26:
print("water class=s4 very high sodium hazard Remarks: Not suitable")
Thank you!
10
0
0
3
x = 5
y = 10
print(x + y)
Thank you!
3
0
4
2
def main(str1, str2):
m = len(str1)
n = len(str2)
j = 0
i = 0
while j < m and i < n:
if str1[j] == str2[i]:
j = j+1
i = i + 1
return j == m
str2 = str(input())
N = int(input())
for i in range(N):
str1 = str(input())
if main(str1, str2):
print("POSITIVE")
else:
print( "NEGATIVE")
Thank you!
2
0
4
9
#Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100 #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)
Thank you!
9
0
4.1
10
# cook your dish here
tc = int(input())
for _ in range(tc):
c = 0
n = int(input())
n = pow(2,n)
for x in range(0,n):
a = x ^ (x+1)
b = (x+2) ^ (x+3)
if(a==b):
c+=1
print(c)
Thank you!
10
0
4
5
''' Program for identify the Bulk density, Particle density, Percent pore space in python (pore space cylinder method)'''
#Get the input via user interaction with the help of the variables w, v1, v1, v4
w=input('Enter the weight of the soil taken in grams:')
v1=input('Enter the volume of soil taken in ml:')
v2=input('Enter the volume of water added in ml:')
v4=input('Enter the volume of soil water at the end of the experiment in ml:')#calculation for soil+water, pore space volume
v3=float(v1)+float(v2)
v5=float(v3)-float(v4)#calculation for bulk density, particle density, pore space
bd=float(w)/float(v1)
pd=float(w)/(float(v1)-float(v5))
pps=(float(v5)/float(v1))*100 #print the soil+water, pore space volume, bulk density, particle density, pore space
print("volume of soil+water:",v3)
print(" pore space volume:",v5)
print("bulk density milligram per meter cube:",bd)
print("particle density:",pd)
print("percent pore space(in percentage):",pps)
Thank you!
5
0
Are there any code examples left?
New code examples in category Python
-
Python 2023-04-11 03:04:20
-
Python 2022-03-27 22:40:04 pycharm no module named
-
Python 2022-03-27 22:25:05 assign multiple variablesin one line
-
Python 2022-03-27 22:20:02 levenshtein distance
-
Python 2022-03-27 21:35:09 get text from url python last slash
-
Python 2022-03-27 21:30:30 df concatenate df
-
Python 2022-03-27 21:25:09 python odd or even
-
Python 2022-03-27 21:15:32 python include function from another file
-
Python 2022-03-27 21:10:01 color module python
-
Python 2022-03-27 21:00:27 python tkinter cursor types