SSITSMentor - CS IP Tasks

SSITSMentor - CS IP Tasks Our objective is to expertise students for career success.We trained students for different computer courses.

We are the mentor for CS and IP subject for school project submissions. We are providing HTML CSS JAVA DotNet Python Mysql any many more courses

Summer computer courses starting soon-for class 10th onward students.reserve your seat
19/04/2023

Summer computer courses starting soon-
for class 10th onward students.
reserve your seat

New Batch For Python course is starting soon
12/02/2023

New Batch For Python course is starting soon

21/05/2022

Python MySql Connection
---------------------------------
The steps to connect the python application to the database.
There are the following steps to connect a python application to our database.

Import mysql.connector module
Create the connection object.
Create the cursor object
Execute the query
-------------------------------------------------
import mysql.connector
from mysql.connector import Error

connection = mysql.connector.connect(host='localhost',
database='Electronics',
user='pynative',
password='pynative@ #29')
if connection.is_connected():
db_Info = connection.get_server_info()
print("Connected to MySQL Server version ", db_Info)
cursor = connection.cursor()
finally:
if connection.is_connected():
cursor.close()
connection.close()
print("MySQL connection is closed")
--------------------------------------------------------------------------

16/05/2022

RDBMS :

RDBMS stands for Relational Database Management System.

It is called Relational Database Management System (RDBMS) because it is based on the relational model introduced by E.F. Codd.

The data in an RDBMS is stored in database objects which are called as tables. This table is basically a collection of related data entries and it consists of numerous columns and rows.The data in an RDBMS is stored in database objects which are called as tables.

This table is basically a collection of related data entries and it consists of numerous columns and rows.Table is the most common and simplest form of data storage in a relational database.

Every table is broken up into smaller entities called fields.A field is a column in a table that is designed to maintain specific information about every record in the table.

Python Function Defination -Function is used for code reusability.When you want to do something repeatedly, you can defi...
30/04/2022

Python Function Defination -

Function is used for code reusability.When you want to do something repeatedly, you can define that as a function and call that function whenever you need in further in that script.

Python Function Syntax
Syntax to define a function in Python:

def function_name(parameters):
# Function Defination
return result

* Use def keyword to define function, give your function a name, followed by a pair of parentheses, and end the line with a colon (:).
* If your function takes arguments, the names of the arguments (parameters) are mentioned inside the opening and closing parentheses.
* In function definition, the arguments that your function consumes are referred to as parameters.
* When you call the function with specific values for these parameters, they're called arguments or actual parameters. This is because the arguments in the function call are the values used for the function's parameters.
* Then, you begin an indented block. This is the body of the function that describes what your function does.
* Return statement that returns the result of the operation on the arguments. The return statement returns control to the point where the function was originally called.
( Note that the arguments and the return statement are optional. This means that you could have a function that takes in no arguments, and returns nothing. )

How to Create a Simple Function in Python

Simple function in Python that greets the user:
=>
def my_func():
print("Hello!")

-----------------------------------------------------------

29/04/2022

// use of function @ python function

8) Simple Calculator
=
def add(x,z):
# This function is used for adding two numbers
return x + z
def subtract(x, z):
# This function is used for subtracting two numbers
return x - z
def multiply(x, z):
# This function is used for multiplying two numbers
return x * z
def divide(x, z):
# This function is used for dividing two numbers
return x /z
# Now we will take inputs from the user
print ("Please select the operation.")
print ("a. Add")
print ("b. Subtract")
print ("c. Multiply")
print ("d. Divide")

choice = input("Please enter choice (a/ b/ c/ d): ")

num_1 = int (input ("Please enter the first number: "))
num_2 = int (input ("Please enter the second number: "))

if choice == 'a':
print (num_1, " + ", num_2, " = ", add(num_1, num_2))

elif choice == 'b':
print (num_1, " - ", num_2, " = ", subtract(num_1, num_2))

elif choice == 'c':
print (num1, " * ", num2, " = ", multiply(num1, num2))
elif choice == 'd':
print (num_1, " / ", num_2, " = ", divide(num_1, num_2))
else:
print ("This is an invalid input")

27/04/2022

5) Reverse of given integer
=>
number = int(input("Enter a positive integer: "))
rev = 0
while(number!=0):
digit = number%10
rev = (rev*10)+digit
number = number//10
print(rev)
-------------------------------------------------------
6) Generate the prime numbers from 1 to N
=>
num =int(input("Enter the range: "))
for n in range(2,num):
for i in range(2,n):
if(n%i==0):
break
else:
print(n)
----------------------------------------------------------
7) To Calculate the sum of the digits in an integer.
=>
num = int(input("Input a four digit numbers: "))
x = num /1000
x1 = (num - x*1000)/100
x2 = (num - x*1000 - x1*100)/10
x3 = num - x*1000 - x1*100 - x2*10
print("The sum of digits in the number is", x+x1+x2+x3)
---------------------------------------------------------------

26/04/2022

3) swap two numbers (using third variable)
=>
x = int( input("Please enter value for x: "))
y = int( input("Please enter value for y: "))
temp_1 = x
x = y
y = temp_1
print ("The Value of x after swapping: ", x)
print ("The Value of y after swapping: ", y)
----------------------------------------------------------
4) to Check if a Number is Odd or Even
(use of % operator)
=>
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("given is Even number".format(num))
else:
print("given is Odd number".format(num))
---------------------------------------------------------------

23/04/2022

1) Write a python program to calculate and print their sum, product and difference of 2 numbers ?
=>
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
s=a+b
x=a*b
if(a>b):
z=a-b
else:
z=b-a
print("Sum = ",s)
print("Product = ",x)
print("Difference = ",z)
---------------------------------------------------------------------
2) Write a python program to check and print the largest number of 3 numbers ?
=>
a=int(input("Enter 1st no "))
b=int(input("Enter 2nd no "))
c=int(input("Enter 3rd no "))
if(a>b and a>c):
m=a
else:
if(b>c):
m=b
else:
m=c
print("Max no = ",m)

22/04/2022

Address

Annapurna And MG Road Indore
Indore

Alerts

Be the first to know and let us send you an email when SSITSMentor - CS IP Tasks posts news and promotions. Your email address will not be used for any other purpose, and you can unsubscribe at any time.

Share