Wednesday, May 5, 2021

Write a program in python which determine determines that the number is prime or not. What is your favorite number?

Write a program in python which determine determines that the number is prime or not. What is your favorite number?

Code 

number = int(input("Enter any number: "))


if number > 1:

    for i in range(2, number):

        if (number % i) == 0:

            print(number, "is not a prime number")

            break

    else:

        print(number, "is a prime number")


else:

    print(number, "is not a prime number")


Output:



Saturday, May 1, 2021

Online "Cyber Security Awareness" quiz link is open now.

 Online "Cyber Security Awareness" quiz link is open now.

Test your knowledge about the cybersecurity and cyber law in India 


1. There is no registration fee.

2. Get free E- Certificate immediately.

3. 60.00% or more marks required to gain the  e-certificate.


Share this with your friends.

Link- https://forms.gle/BAW8th21NA7tSWzQ8


Regards

Er. Talwinder Singh, 

Cyber security researcher,

Cyber Suraksha Sheild

 

Website-http://cybersurakshashield.ga/

email- cyber.suraksha.shield@gmail.com

blog- https://cybersurakshashield.blogspot.com

FB page - https://m.facebook.com/cybersurakshashield

Thursday, April 15, 2021

Draw a big sized star with multi color using python code

Draw a big sized star with multi color using python code 

Code:-

 import turtle

 

colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']

t = turtle.Pen()

turtle.bgcolor('black')

for x in range(1,360,4):

    t.pencolor(colors[x%6])

    t.width(x/360 + 1)

    t.forward(x)

    t.left(144)


turtle.done()


Output:-



Draw a beautiful diagram using Turtle (Python)

Draw a beautiful diagram using Turtle (Python)

Code:-

 import turtle

 

colors = ['red', 'purple', 'blue', 'green', 'orange', 'yellow']

t = turtle.Pen()

turtle.bgcolor('black')

for x in range(1,360,2):

    t.pencolor(colors[x%6])

    t.width(x/360 + 1)

    t.forward(x)

    t.left(150)


turtle.done()

Output :-





Wednesday, April 14, 2021

Second program of OBJECT ORIENTED PROGRAMMING USING JAVA (Diploma CSE/IT 2018, Syllabus)

In a software company Software Engineers, Sr. Software Engineers, Module Lead, Technical Lead, Project Lead, Project Manager, Program Manager, Directors all are the employees of the company but their work, perks, roles, responsibilities differs. Create the Employee base class would provide the common behaviors of all types of employee and also some behaviors properties that all employee must have for that company. Also include search method to search an employee by name.


Code:- 

import java.util.*;

public class Employee 

{

String name;

String role;

String work;

    String perks;

    String responsibility;

    public Employee() 

{

//System.out.println("\nDefault Constructor");

    }

    public void Create(String n, String r, String w, String p, String rs)

{

        name=n;

role=r;

work =w;

perks=p;

responsibility=rs;

    }

public void display()

{

System.out.println("Name - \t\t"+name);

System.out.println("Role - \t\t"+role);

System.out.println("Work - \t\t"+work);

System.out.println("Responsibility - \t"+responsibility);

System.out.println("Perks or salary - \t"+perks);

}

}

class Emp_Main extends Employee

{

static Employee[] emp;

public static int search(String nn)

{

System.out.println("Search for = "+nn+"\n");

for (int i = 0; i <emp.length; i++) 

{

if (emp[i].name.equals(nn))

{

System.out.println(" "+nn+" found ...\n details are following ");

emp[i].display();

return 0;

}

}

System.out.println(" "+nn+" not found ...");

return 1;

}

public static void main(String ta[])

{

System.out.println("\t ----- CODING ADDA -----");

emp= new Employee[8];

emp[0] =  new Employee();

emp[1] =  new Employee();

emp[2] =  new Employee();

emp[3] =  new Employee();

emp[4] =  new Employee();

emp[5] =  new Employee();

emp[6] =  new Employee();

emp[7] =  new Employee();

emp[0].Create("Mr Raj","Software Engineers","Software Engineers","50,000","Responsible for Software Development");

emp[1].Create("Mr ALEX"," Sr. Software Engineers"," Sr. Software Engineers","60,000","Supervision");

emp[2].Create("Miss Tanu","Module Lead","Module Lead","63,000","Module related responsibility");

emp[3].Create("Miss Manu","Technical Lead","Technical Lead","40,000","Technical Leader related responsibility");

emp[4].Create("Mr Vikram","Project Lead","Module Lead","35,000","Module related responsibility");

emp[5].Create("Mr Talwinder Singh","Directors","Directors","150,000","all responsibility of Directors");

emp[6].Create("Mr Sandeep Khehra ","Program Manager","Program Manager","60,000","all responsibility of Program Manager");

emp[7].Create("Miss Manveen Kaur","Project Manager","Project Manager","65,000","all responsibility of Project Manager");

Scanner sc= new Scanner(System.in); //System.in is a standard input stream.

System.out.print("\n Enter a Name of Employee you want to search: ");

String nn= (String) sc.nextLine(); //reads string.

search(nn);

}

}


Output:- 

1.

2. 




Sunday, April 11, 2021

First program of OBJECT ORIENTED PROGRAMMING USING JAVA (Diploma CSE/IT 2018, Syllabus)

1. Consider we have a Class of Cars under which Santro Xing, Alto and WaganR represents individual Objects. In this context each Car Object will have its own, Model, Year of Manufacture, Colour, Top Speed, etc. which form Properties of the Car class and the associated actions i.e., object functions like Create(), Sold(), display() form the Methods of Car Class. Use this class to create another class Company that tracks the models it create.


CODE- 

public class Car 

{

    String model;

    int man_year;

    String color;

    String top_speed;

    public Car() 

{

System.out.println("\nDefault Constructor");

        }

    public void Create(String m, int yy, String c, String ts)

{

        model=m;

man_year=yy;

color=c;

top_speed=ts;

    }


public void Sold()

{

System.out.println("This car is sale on cash");

}


public void display()

{

System.out.println("Model - \t\t"+model);

System.out.println("Year of manufacture - \t"+man_year);

System.out.println("Colour - \t\t"+color);

System.out.println("Top Speed of car - \t"+top_speed);

}

public static void main(String ta[])

{

System.out.println("-----main method-----");

Car Santro= new Car();

Santro.Create("Santro Xing",2020,"Black","240 KM per hour");

System.out.println("\n-----Santro Xing car Detail-----");

Santro.display();

Car Alto= new Car();

Alto.Create("Alto 800",2021,"Red","300 KM per hour"); 

System.out.println("\n-----Alto car Detail-----");

Alto.display();

Car Waganr= new Car();

Waganr.Create("2020",2020,"Black","280 KM per hour");

System.out.println("\n----- Waganr car Detail-----");

Waganr.display();

Waganr.Sold();

}

}


Output- 




Saturday, June 20, 2020

Copy the existing file(i.e jpg/png file) and create a new file with new name

Copy the existing file(i.e jpg/png file) and create a new file with new name using java code.
or
The Use of FileInputStream and FileOutStream.


import java.io.*;
class FInOutStream
{
public static void main(String args[]) throws Exception
{
FileInputStream read=null;
FileOutputStream write=null;
int c, count=0;
try
{
File src=new File("CodingAdda.png"); //Name of Source File which already exist
read=new FileInputStream(src);

File des=new File("temp.png"); //Name of file which you want to create
write= new FileOutputStream(des);

while((c=read.read())!=-1)
{
write.write(c);
count++;
}
System.out.println(count+" byte Copied.........");
}
catch(Exception ex)
{
ex.printStackTrace();
}

try
{
read.close();
write.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
Output: 



Show No of Bytes copied


show new File (temp.png)

Write a program in python which determine determines that the number is prime or not. What is your favorite number?

Write a program in python which determine determines that the number is prime or not. What is your favorite number? Code   number = int(inpu...