Klouds AnCyber Technologies Pvt Ltd

Area and Circumference of Circle in Python

Objectives:

  • How to find the area of a circle in Python?
  • How to find the circumference of a circle in Python?
  • How to find the area and circumference of a circle in Python?

Python Code:

[sourcecode lang=”python”]

print("Enter radius of circle")
rad = input()
r=float(rad)
area = 3.14 * r * r
circumference = 2 * 3.14 * r
print(area)
print(round(circumference, 2))

[/sourcecode]

Steps to Run the above code:

  • Navigate to the folder/directory where you have saved your python code or file.
  • Here I have considered that python file is saved on “c:\>” and the File name is “Circle.py
  • Just type the following command now to execute the Python program: c:\> python Circle.py

 

Download code:

  • Navigate to GitHub repository and download the code from here: Circle.py

 

We conduct Python Training and Workshop for Corporates and College Students, if interested, please write to us on kloudsancyber@gmail.com

 

Aatul Palandurkar
Life Coach, International Trainer, and Author

https://www.facebook.com/aatulpalandurkar
https://www.instagram.com/aatulpalandurkar/

How to spoof or fake GPS location in Marshmallow?

Android Tutorials

Android Tutorials

Objectives :

  • How to spoof GPS location in Marshmallow?
  • How to fake GPS location in Marshmallow?

To spoof / fake GPS location in Marshmallow follow the steps below :

  1. Go to “Settings”
  2. Go to “About phone”
  3. Scroll to the bottom until you see Build Number.
  4. Repeatedly tap it until you unlock “Developer options”
  5. Go back to “Settings”
  6. Right above “About phone”, you will now see “Developer options”.
  7. Look for “Select mock location app”
  8. Click on this to select the app you use to GPS spoof.

 

Subscribe blog for more updates.

Passing data between activities in Android

Objective :

  • Passing data between activities in Android
  • Passing multiple data between activities in Android
  • Passing array between activities in Android
  • Passing ArrayList between activities in Android
  • Passing ArrayList to another activity in Android
  • Sending data via Intent in Android
  • Sending multiple data via Intent in Android
  • Sending array between activities in Android
  • Sending ArrayList between activities in Android
  • Sending ArrayList to another activity in Android
  • Sending data via Intent and Bundle in Android
  • Sending multiple data via Intent and Bundle in Android
  • Passing array between activities in Android using Intent and Bundle
  • How to pass array to another activity in Android?
  • How to pass array between activities in Android?
  • How to pass data to another activity in Android?
  • How to pass data to activity in Android?
  • How to pass data to between activities in Android?
  • How to pass ArrayList to another activity in Android?
  • How to pass ArrayList between activities in Android?

 

Code for passing data between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]

String value = "Hello!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key", value);
startActivity(in);

[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]

Bundle bundle = getIntent().getExtras();
String valueReceived = bundle .getString("Key");

[/sourcecode]

 

Code for passing multiple data or values between activities in Android :

Method 1 : Using Intent to pass data and Bundle to extract data between activities in Android

ActivityOne.java

[sourcecode lang=”java”]

String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
in.putExtra("Key1", value1);
in.putExtra("Key2", value2);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]

 

Method 2 : Using Bundle to pass and to extract data between activities in Android

ActivityOne.java

[sourcecode lang=”java”]

String value1 = "Hello!";
String value2 = "Hi!";
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putString("Key1", value1);
bundle.putString("Key2", value2);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String valueReceived1 = bundle .getString("Key1");
String valueReceived2 = bundle .getString("Key2");
[/sourcecode]

 

Code for passing array between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]
String[] array = new String[]{"Item1", "Item2", "item3", "Item4", "item5"};
Intent in = new Intent(this,ActivityTwo.class);
Bundle bundle = new Bundle();
bundle.putStringArray("MyArray", array);
in.putExtras(bundle);
startActivity(in);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
String arrayReceived[] = bundle.getStringArray("MyArray");
[/sourcecode]

 

Code for passing ArrayList between activities in Android :

ActivityOne.java

[sourcecode lang=”java”]
ArrayList<String> array = new ArrayList<String>();
array.add("Hello");
array.add("Hi");
array.add("Bye");
Intent intent = new Intent(this, ActivityTwo.class);
intent.putExtra("array_list", array);
startActivity(intent);
[/sourcecode]

ActivityTwo.java

[sourcecode lang=”java”]
Bundle bundle = getIntent().getExtras();
ArrayList<String> array = (ArrayList<String>) bundle.getStringArrayList("array_list");
[/sourcecode]


Have fun with Intent.

Java Program to find prime number upto N number

Objectives :

  • Write a Java program to find prime number upto N number
  • Write a Java program to print prime number upto N number
  • Write a Java program to find prime number upto N number using Command Line Arguments
  • Write a Java Program to find prime number upto N number via Command Line Arguments
  • Write a Java program to find prime number upto N number using Scanner class

 

Java Program / Code :

Method 1 : Java Program to find Prime Number upto N number using Scanner class

[sourcecode lang=”Java”]

import java.util.Scanner;
class PrimeNumber
{
public static void main(String[] args)
{
int n,p;
Scanner s=new Scanner(System.in);
System.out.println(“Enter number : ”);
n=s.nextInt();
for(int i=2;i<n;i++)
{
p=0;
for(int j=2;j<i;j++)
{
if(i%j==0)
p=1;
}
if(p==0){
System.out.println(i);
}
}
}
}
[/sourcecode]

Method 2 : Java Program to find Prime Number upto N number using Scanner class and writing function to find prime number

Method isPrime() for checking if a number is prime or not

[sourcecode lang=”java”]
public class PrimeNumber{
public boolean isPrime(int num) {
if ( num < 2 ){
return false;
}
for (int i = 2; i <= Math.sqrt(num); i++) {
if ( num % i == 0 ) {
return false;
}
}
return true;
}
}

// Mock Test Class to test above code
import java.util.Scanner;

public class Demo
{
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);

System.out.println("Please enter a number: ");
int num = scanner.nextInt();

if ( num < 2 ) {
System.out.println("\n There are no Prime Numbers available");
System.exit(0);
}
System.out.println("\n Prime Numbers from 1 to "+ num);
PrimeNumber primeNum = new PrimeNumber();

for (int i = 3; i <= num; i++) {
if ( primeNum.isPrime(i) ) {
System.out.print(", " + i);
}
}
}
}
[/sourcecode]

Method 3 : Java Program to find Prime Number upto N number using Command line input

[sourcecode lang=”Java”]

class PrimeNumber
{
public static void main(String[] args)
{
int n,p;
n=Integer.parseint(args[0]);
for(int i=2;i&lt;n;i++)
{
p=0;
for(int j=2;j&lt;i;j++)
{
if(i%j==0)
p=1;
}
if(p==0){
System.out.println(i);
}
}
}
}
[/sourcecode]

Steps to run above program via command line :

  1. Compilation : C:\JavaPrograms>javac PrimeNumber.java
  2. Interpretation : C:\JavaPrograms>java PrimeNumber 20

Output :

2

3

5

7

11

13

17

19

Buy Online Freedom 251 Booking/Register at freedom251.com

Ringing-Bells-Freedom-2513

Register Now to Buy Freedom 251 Mobile Phone: Cheapest Smartphone Launched by Ringing Bells Booking starting on – 18 Feb 2016

Ringing Bells has launched the cheapest Smartphone Freedom 251 in India which is priced Rs 251. The company launched this phone on February 17, 2016. The phone is launched by Union Defence Minister Manohar Parrikar. The freedom 251 is queued with the Prime Minister Narendra Modi’s vision of empowering India. The is aimed at providing people Freedom to Flaunt, Freedom to Capture, Freedom to Connect, Freedom to Explore and Freedom to Talk.

Latest NEWS about Freedom 251 Mobile Phone:

The Online Freedom 251 Mobile sale is stopped today because of heavy traffic on the site, the company decide to resume to Online Mobile booking by tomorrow on 19th Feb 2016. It is not confirmed news but hope for the best and visit the page again to check the available option for Freedom 251 registration. If you have any more news about Freedom 251 mobile phone then use comment section to give inputs.

Still it is  unclear that whether Ringbell Freedom 251 will be available on Paytm, Flipkart, Snapdeal or Amazon.com. We will update you if the Smartphone will be available for sale online on said sites. Meanwhile you can register for Freedom 251 on the given below link so you can cross the first step.

Freedom 251 Customer Care Number

0120-4200470, 6619680, 4001000

What is the next Freedom 251 Booking Timing and Launch Date

Mobile launched on 18 Jan 2016 but due to heavy traffic on site it postponed to tomorrow on 19 Feb 2016. Hopefully everything will be alright and again mobile will be ready for registration or buying.

Sale starts on 18th Feb 2016

New booking date – 19th Feb 2016

Closing on – 21st Feb 2016 at 8 PM

The government Mobile Freedom 251 was unveiled in grand ceremony on 17 Feb 2016 by Shri Manohar Parrikar. The mobile development got full support from Shri Narendra Modi government under the Make in India yojana. The phone comes with one year additional warranty.

How to buy Freedom 251 Mobile Phone

Visit the freedom251.com from your internet enabled mobile/laptop and click the buy button given on the site. Rest procedure is very simple, just have to put the right information, you used to provide on the online shopping sites like Flipkart, amazon, Ebay, Paytm and Shopclues.

Registration of Mobile is starting 18 Feb 2016 at 6 PM. so Buy Freedom 251 Mobile – Click here to register

Buy Online Freedom 251 on Amazon/ Flipkart, Launched by Ringing Bells on Wednesday 17 February 2016, Cheapest Smartphone on Amazon/ Flipkart   

Ringing Bells Freedom 251 Specs:  The 1.3 GHz Quadcore Processor of Freedom 251 gives you fast and responsive performance. The phone has enough storage space of 1GB RAM and 8GB internal memory. It supports SD card which is expandable up to 32 GB. The 1450 mAh battery of the Smartphone gives you enough time without charging in between to use the mobile phone for talking, watching video or playing games. The 4 inch Smartphone has HD display and it gives you freedom to watch videos, images and to play games. The 3.2 Mega Pixel auto focus camera and 0.3 Mega Pixel front camera gives you freedom to capture images and have facility to take Selfie in reliable cost of the Smartphone. You will remain connected to your family and friends anytime and anywhere.

Flipkart Freedom 251– Available Soon  

Ebay Freedom 251 Mobile – Not Available

Paytm Freedom 251 Cellphone – Not Available

Amazon Freedom 251– Available Soon

You get 1 year of warranty on Freedom 251, the cheapest Smartphone manufactured in India. There are more than 650 service centres present across India. Dual SIM, front camera, 3G GSM and many more features are available in Smartphone at only Rs 250. You can enjoy the freedom through the lowest price Smartphone.

Freedom 251 Mobile Price in India – Rs 251 Only

Once Freedom 251 Phone available online, we will let you the procedure to How to buy Freedom 251 Mobile Phone from Flipkart, Snapdeal, Amazon India & Paytm.com. Till then wait for news. Just log on the freedom251.com and buy this cheapest mobile.

Source : Promo Coders

How should a trainer handle rude participants in a training workshop?

Objectives:

  • How should a trainer handle rude participants in a training workshop?
  • Do’s and Don’ts for Trainer

The ability to handle rude participants is critical to success as a trainer as each trainer has at one or the other time encountered rude participants. The participants who continue talking, who work on their laptops while you are training, who continuously attend calls on their mobiles, who flat out say you are wrong or you have no clue what it is to be in their shoes, participants who recline on their chairs as if they are in a lounge, who ask irrelevant questions…. the list is endless.

So, what can you do to prevent rude participants from derailing or hijacking a training workshop?

1. Do some pre-work to ensure a great learning environment: Many things impact a participant even before they meet you: how was the training need communicated to them? Do they think they NEED training? etc. Many times these are out of our control but I like to request clients to copy me on emails they send to the participants.

2. Invest some time in the beginning of the session establishing your credibility and getting them to articulate why they should invest their time learning what you are going to cover.

3. Set the training norms collaboratively upfront: your expectations from them, their expectations from you should be on the table and any misalignment needs to be handled. Here come issues like late to class, talking instead of doing assignments etc. Discuss course of action if someone oversteps the boundaries that you all have collaboratively set. Agree on how you will handle disagreements if any i.e. agree on how to disagree.

So, basically we attempt to pre-empt rudeness.

If after all of this, someone is rude, then we can take recourse to some of the following strategies:

1. Isolate what form the rudeness is taking: talking amongst themselves, asking irrelevant questions, negative body language, refusal to engage in any of the activities etc.

2. If the rude participants are in a group, split up the group by doing an activity in which you shift people around in the room. My favourite is to use numbers to divide people into groups as it ensures people who are sitting together are not in the same group.

3. Move the rude participants to the front of the room. Basically near you. Now shower them with your keen attention.

4. Redirect their attention by making them participate in the training activities. Use persuasion.

5. For one off comments, say “interesting point of view, lets discuss in the tea break”, and move on without getting affected.

6. If they are asking questions or expressing views, give the participant a patient hearing and try to see it from their perspective. Let them fully express themselves, then if the question is pertinent to the topic answer it. You can also ask for their permission to park the question and answer it later. If they feel heard they will allow that.

7. Be assertive. Tell them that while you appreciate their views, you have differing views. You could also say that since their concern is not the concern of the majority you will handle it post the session.

8. If time is not permitting then tell them you will discuss it with them in the break. Then do not forget to do so.

9. Do not let it get personal. It should not be your view vs. theirs. Ask other participants for their take on the issue / question. Then wrap up with summarizing the views.

10. Humour if used appropriately, can work wonders.

Simple Interest Example in Java

Starting a series of some Java programs as many students were asking to share the programs. Here is the first program of the series.

Objectives:

  • Write a Program that calculates and prints the simple interest using the formula : Simple Interest = PTR/100
  • How to calculate Simple Interest in Java?
  • Write a program to calculate Simple Interest in Java.
  • Write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.
  • How to use Command Line Arguments in Java?
  • How to pass values from command line in Java?
  • How to take input in Java from console?

 

This particular program can be written in various ways, we will try to write the solution program in different ways here and one can try to understand the difference between them.

Method 1 :

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {

int p,t,r, result;

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextInt();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextInt();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextInt();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

This one is the simplest way to write the program to find simple interest in Java. Here we have simply created the object of Scanner class for taking input. Scanner class was introduced in Java 6. To use Scanner class we will have to import the class from java.util package.

Method 2:

Now we will write a Java program that calculates and prints the simple interest using the Scanner class again but with object oriented programming approach.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample
{
double principalAmount = 0;
double interestRate = 0;
double term = 0;
double simpleInterest = 0;

public void calculateSimpleInterest()
{
Scanner input = new Scanner(System.in);

System.out.print(&quot;Enter the Principal amount : &quot;);
principalAmount = input.nextDouble();

System.out.print(&quot;Enter the Rate As a decimal : &quot;);
interestRate = input.nextDouble();

System.out.print(&quot;Enter the amount of time in years : &quot;);
term = input.nextDouble();

simpleInterest = (principalAmount * interestRate * term) / 100;
}

public void displaySimpleInterest()
{
System.out.println(&quot;The Simple Interest is : &quot; + simpleInterest);
}
}
[/sourcecode]

Mock Test Program for above code so that we can test the code. keep both the classes in same package and run the Mock Test Program or MockTestProgram.java

[sourcecode lang=”java”]
public class MockTestProgram{

public static void main(String[]args);
{
SimpleInterestExample simpleInt = new SimpleInterestExample();
simpleInt.calculateSimpleInterest();
simpleInt.displaySimpleInterest();
}
}
[/sourcecode]

Method 3:

Now we will write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {
double p,t,r, result;

p = Double.parseDouble(args[0]);
t = Double.parseDouble(args[1]);
r = Double.parseDouble(args[2]);

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextDouble();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextDouble();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextDouble();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

 

I will be sharing more programs soon as many students were asking for programs which were carried out during Java training and were asked in assignments after Java training. By the time enjoy coding in Java and use NetBeans, it will ease your life.