#Program to print any table of any number entered by user
#Name and Roll Number
import math
n = int(input('Enter any number whose table you want to print: '))
print('Table of', n, 'is given by\n')
for i in range(1, 11):
print(n, 'x', i, '=', n * i)
Monday, 10 March 2025
Python Program to print any table of any number entered by user
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Copy Copied! #Program to print any table of any number entered by user #Name and Roll Number import...
-
Copy Copied! #program to find solution of quadratic equation #Name and Roll #Quadratic equation i...
-
Copy Copied! #Experiment No 4:Program to solve a linear differential equation using SciKit and pol...
#37.Tushar k. Patil
ReplyDelete#Program to read students result file and plot normalization curve
import pandas as pd
import matplotib.pyplot as plt
from scipy.stats import norm
import statistics as st
import numpy as np
#Read the student's results file
df=pd.read_csv("")
#Replace'AB' with NaN for better handling of absent students
df.replace('AB',np.nan,inplace=True)
#Extract columns for each subject
rn=df['Roll No']
sub_em4=df['EM-4'].dropna().astype(float)
sub_FM=df['FM'].dropna().astype(float)
sub_kom=df['KOM'].dropna.astype(float)
sub_cadcam=df['CAD/CAM'].dropna.astype(float)
sub_ie=df['IE'].dropna.astype(float)
#Function to calculate and plot normalization curve for each subject
def plot_normalization_curve(subject,title,color):
mean=st.mean(subject)
sd=st.stdev(subject)
x_values=np.linspace(mini(subject),max(subject),100)
y_values=norm.pdf(x_values,mean,sd)
plt.plot(x_values,y_values,label=f'{title}Normal Distribution',color=color)
plt.hist(subject,bins=18,density=True,alpha=0.5,color=color,edgecolor='black')
plt.title(f'{title}Marks')
plt.xlabel('Marks')
plt.ylabel('Density')
plt.legend()
#Set general plot dimensions
plt.rcParams["figure.figure"]=(20,15)
#Create subplots for each subject
plt.subplot(2,3,1)
plot_normalization_curve(sub_em4,'EM-4','blue')
plt.subplot(2,3,2)
plot_normalization_curve(sub_fm,'FM','green')
plt.subplot(2,3,3)
plot_normalization_curve(sub_kom,'KOM','red')
plt.subplot(2,3,4)
plot_normalization_curve(sub_cadcam,'CAD/CAM','purple')
plt.subplot(2,3,5)
plot_normalization_curve(sub_ie,'IE','orange')
#Set the global title
plt.suptitle("Normality check of students scores using histograms")
#Show the plot
plt.tight_layout(rect=[0,0.003,1,0.95])
plt.show()
import pandas as pd
ReplyDeleteimport matplotlib.pyplot as plt
from scipy.stats import norm
import statistics as st
import numpy as np
# Read the student's result file
df = pd.read_csv("C:\\Users\\mechsim-07\\Downloads\\grades.csv")
# Replace 'AB' with NaN for better handling of absent students
df.replace('AB', np.nan, inplace=True)
# Extract columns for each subject
rn = df['Roll No']
sub_em4 = df['EM-4'].dropna().astype(float)
sub_fm = df['FM'].dropna().astype(float)
sub_kom = df['KOM'].dropna().astype(float)
sub_cadcam = df['CAD/CAM'].dropna().astype(float)
sub_ie = df['IE'].dropna().astype(float)
# Function to calculate and plot normalization curve for each subject
def plot_normalization_curve(subject, title, color):
mean = st.mean(subject)
sd = st.stdev(subject)
x_values = np.linspace(min(subject), max(subject), 100)
y_values = norm.pdf(x_values, mean, sd)
plt.plot(x_values, y_values, label=f'{title} Normal Distribution', color=color)
plt.hist(subject, bins=18, density=True, alpha=0.5, color=color, edgecolor='black')
plt.title(f'{title} Marks')
plt.xlabel('Marks')
plt.ylabel('Density') # Corrected this
plt.legend()
# Set general plot dimensions
plt.rcParams["figure.figsize"] = (20, 15)
# Create subplots for each subject
plt.subplot(2, 3, 1)
plot_normalization_curve(sub_em4, 'EM-4', 'blue')
plt.subplot(2, 3, 2)
plot_normalization_curve(sub_fm, 'FM', 'green')
plt.subplot(2, 3, 3)
plot_normalization_curve(sub_kom, 'KOM', 'red')
plt.subplot(2, 3, 4) # Corrected this line
plot_normalization_curve(sub_cadcam, 'CAD/CAM', 'purple')
plt.subplot(2, 3, 5)
plot_normalization_curve(sub_ie, 'IE', 'orange')
# Set the global title
plt.suptitle("Normality check of students' scores using histograms")
# Show the plot
plt.tight_layout(rect=[0, 0.03, 1, 0.95])
plt.show()
// Include the necessary libraries
ReplyDelete#include
// Define the pins for the PIR sensor and motor
#define PIR_PIN 2
#define MOTOR_PIN 3
// Create a servo object for the motor
Servo motor;
// Initialize the PIR sensor pin as input and motor pin as output
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(MOTOR_PIN, OUTPUT);
// Attach the motor to the motor pin
motor.attach(MOTOR_PIN);
}
// Main loop
void loop() {
// Read the value from the PIR sensor
int pirValue = digitalRead(PIR_PIN);
// If the PIR sensor detects motion (human hand), turn off the motor
if (pirValue == HIGH) {
motor.write(0); // Set the motor to 0 degrees (off)
}
}
// Reference: https://www.arduino.cc/en/Tutorial/BuiltInExamples/StateChangeDetection
exp6.py
ReplyDeleteIndex(['Car', 'Model', 'Volume', 'Weight', 'CO2'], dtype='object')
Enter the engine weight in kg: 2300
Enter the engine volume in cubic centimeters: 1300
C:\Users\mechsim-18\AppData\Local\Programs\Python\Python312\Lib\site-packages\sklearn\utils\validation.py:2739: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names
warnings.warn(
The predicted value of CO2 emission based on the engine weight and engine volume is = [107.2087328]
If the weight increases by 1kg, the CO2 emission increases by 0.0075509472703006895 grams
If the engine size (volume) increases by 1cm³, the CO2 emission increases by 0.007805257527747124 grams
#experiment 6
ReplyDelete#example of machine learning to predict the co2 emission of a car based on the size of the engine,but
#with multiple regression we can throw in more variables, like the weight of the car, to make the prediction more accurate.
import pandas
from sklearn import linear_model
df=pandas.read_csv("C:\\Users\\mechsim-18\\Downloads\\data.csv")
X = df[['Weight', 'Volume']]
y = df['CO2']
regr=linear_model.LinearRegression()
regr.fit(X,y)
#predict the co2 emission of a car where the weight is 2300kg, and the volume is 13oocm:
w = float(input('Enter the engine weight in kg: '))
v = float(input('Enter the engine volume in cubic centimeters: '))
predictedCO2 = regr.predict([[w,v]])
print('\nThe predicted value of CO2 emission based on the engine weight and engine volume is =\n', predictedCO2)
print('nIf the weight increases by 1kg, the CO2 emission increases by',regr.coef_[0], 'grams')
print('If the engine size (volume) Increases by 1cm3, the CO2 emission increases by', regr.coef_[1], 'grams')
#Experiment 8b)-Program to plot SFD and BMD of Simply Supported Beam under the point load
ReplyDeleteimport numpy as np
import matplotlib.pyplot as plt
P= float(input('load = '))
ul = input('load unit = ')
L= float(input('Length of the beam = '))
u2= input('length unit = ')
a = float(input('Distance of Point load from left end = '))
b=L-a
R1Pb/L #reaction force at the left support
R2P-R1 #reaction force at the right support
R1= round(R1.3)
R2= round(R2.3)
print(f"'
As per the static equilibrium, net moment sum at either end is zero,
hence Reaction R1 = P*b/L = {R1} (ul),
Also Net sum of vertical forces is zero,
hence R1+R2 = P, R2 = P-R1 = {R2} {ul}.
"")
1 = np.linspace(0, L, 1000)
X = []
SF = []
M = []
maxBM= float()
for x in 1:
if x <= a:
m = R1*x
sf = R1
elif x > a:
m = R1*x - P*(x-a)
I
sf = -R2
M.append(m)
X.append(x)
SF.append(sf)
print(f'""
Shear Force at x (x<{a}), Vx = R1 ={R1) (ul)
at x (x>{a}), SF = R1 - P = (R1) - (P) = -(R1-P) (ul)
Bending Moment at x (x<{a}), Mx = R1*x = (R1)*x
at x (x>=(a)), Mx = RI*x-P*(x-{a})
= {R1}x-{P}(x-{a}) = -(R2}x+ {P*a}
"")
max_SF = 0
for k in SF:
if max_SF =a:
Mx = R1*x-P*(x-a)
if maxBM == Mx:
print(f'maximum BM at x = (round(x,3)] (u2}')
I
plt.plot(X, SF)
plt.plot([0, L], [0, 0])
plt.plot([0, 0], [0, R1], [L, L], [0, -R2])
plt.title("SFD")
plt.xlabel("Length in m")
plt.ylabel("Shear Force")
plt.show()
plt.plot(X. M)
plt.plot([0, L], [0, 0])
plt.title("BMD")
plt.xlabel("Length in m")
plt.ylabel("Bending Moment")
plt.show()
#Experiment No 9 Python Program to process above csv data file and print Amplitude v/s Time plot on
ReplyDeletethe output screen
import pandas
import numpy as np
import matplotlib.pyplot as plt
import statistics as st
#read the csv data file and assign df as the object to access the same
df = pandas.read_csv("expt9-data.csv")
#as per the column heads assign them to two different lists
t = df['Time']
y = df['v0']
#using stats module find the mean of amplitude
m0 = st.mean(y)
#print the value of time and amplitude
print(t)
print(y)
#plot the amplitude v/s time plot
plt.plot(t,y,color='brown')
plt.axhline(y=m0,color='black',ls='-.')
plt.xlabel('Time in Seconds')
plt.ylabel('Amplitude')
plt.title('Amplitude v/s Time Plot')
plt.show()