Tuesday, September 10, 2019

prime number using python

# Python program to check if the input number is prime or not

num = 407

# take input from the user
# num = int(input("Enter a number: "))

# prime numbers are greater than 1
if num > 1:
   # check for factors
   for i in range(2,num):
       if (num % i) == 0:
           print(num,"is not a prime number")
           print(i,"times",num//i,"is",num)
           break
   else:
       print(num,"is a prime number")
     
# if input number is less than
# or equal to 1, it is not prime
else:
   print(num,"is not a prime number")

Arduino Default Fuse bits

Arduino Default Fuse Settings

Here are the default fuse settings for each Arduino from the boards.txt included with the Arduino development software.
To understand more about the fuse settings for your microcontroller, visit Engbedded’s AVR Fuse Calculator.
To write fuse settings, you will need a programmer with this capability. I use Mighty Ohm’s high-voltage rescue shield available here.

Arduino Uno

Low Fuse0xFF
High Fuse0xDE
Extended Fuse0x05

Arduino Duemilanove or Nano w/ ATmega328

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0x05

Arduino Diecimila, Duemilanove, or Nano w/ ATmega168

Low Fuse0xFF
High Fuse0xDD
Extended Fuse0x00

Arduino Mega 2560

Low Fuse0xFF
High Fuse0xD8
Extended Fuse0xFD

Arduino Mega (ATmega1280)

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0xF5

Arduino Mini

Low Fuse0xFF
High Fuse0xDD
Extended Fuse0x00

Arduino Fio

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0x05

Arduino BT w/ ATmega328

Low Fuse0xFF
High Fuse0xD8
Extended Fuse0x05

Arduino BT w/ ATmega168

Low Fuse0xFF
High Fuse0xDD
Extended Fuse0x00

LilyPad Arduino w/ ATmega328

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0x05

LilyPad Arduino w/ ATmega168

Low Fuse0xE2
High Fuse0xDD
Extended Fuse0x00

Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0x05

Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168

Low Fuse0xFF
High Fuse0xDD
Extended Fuse0x00

Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

Low Fuse0xFF
High Fuse0xDA
Extended Fuse0x05

Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168

Low Fuse0xC6
High Fuse0xDD
Extended Fuse0x00

Arduino NG or older w/ ATmega168

Low Fuse0xFF
High Fuse0xDD
Extended Fuse0x00

Arduino NG or older w/ ATmega8

Low Fuse0xDF
High Fuse0xCA

Monday, September 9, 2019

vi editor commands

vi filename.ext create the new file in the pwd.
"i"-------insert the cursor
"a"----write after cursor
"A"----write at the end of the line
:w----quit from the current file
:wq---save and quit from the current file
ESc----terminate from insert mode
:g/^$/d--------remove all empty line from the current file
shift+zz-----exit from the current file

Thursday, August 29, 2019

Replace, Join, Split, Reverse, Uppercase & Lowercase in python


del keyword usage in python

"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
f = 11;
print(f)
  del f
print(f)

output:
    del f
    ^
IndentationError: unexpected indent

global key word usage in python

"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
f = 101;
print(f)
# Global vs.local variables in functions
def someFunction():
  global f
  print(f)
  f = "changing global variable"
someFunction()
print(f)


output:
101
101

changing global variable

declaration and re-declaration of the variable


"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
# Declare a variable and initialize it
f = 0
print(f)
# re-declaring the variable works
f = 'guru99'
print(f)

output:
0
guru99





example 3:


"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
# Declare a variable and initialize it
f = 101
print(f)
# Global vs. local variables in functions
def someFunction():
# global f
    f = 'I am learning Python'
    print(f)
someFunction()
print(f)

output:
101
I am learning Python

101

defination in python

"""
Created on Thu Aug 29 16:29:56 2019
@author: anil durgam
date:29-08-2019
"""
def main():
    print("hello world\n");
   
if __name__ =="__main__":
    main()
   
print("testing")

Wednesday, August 28, 2019

NUMBER SERIES BASIC TESTING

/**************************************************
** written by :ANIL DURGAM
** NUMBER SERIES TESTING VER 1.0
**DATE:29-08-2019
**************************************************/



#include <stdio.h>
#include <stdlib.h>

int main()
{
    int first_num,sec_num,third_num,fourth_num,next_number;
    int first_diff,second_diff,third_diff,fourth_diff;
    printf("please enter the FOUR number after every number hit ENTER\n");
    scanf("%d%d%d%d",&first_num,&sec_num,&third_num,&fourth_num);
    printf("first number=%d,\nsecond number=%d,\nthird number=%d,\nfourth number=%d\n",first_num,sec_num,third_num,fourth_num);
    first_diff=sec_num-first_num;
    second_diff=third_num-sec_num;
    third_diff=fourth_num-third_num;
    if(first_diff==second_diff)
    {
        if(third_diff==second_diff)
        {
            next_number=first_diff+fourth_num;
            printf("next number is ==%d\n",next_number);
        }
        else
        {
            printf("third and fourth number is not matching\n");
        }
    }
    else{

        printf("number not matching\n");
    }

    return 0;
}


OUTPUT:
please enter the FOUR number after every number hit ENTER
12
24
36
48
first number=12,
second number=24,
third number=36,
fourth number=48


next number is ==60

format type in c language

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a=789,b=1234;
    printf("a=%3d, b=%4d", a, b);
    return 0;
}

output:
a=789,b=1234

input is
a=9,b=4;
a=  9, b=   4


"\r" carriage return in c programming language

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello \rworld!\n");
    return 0;
}


output :
world

because of \r in the printf statement....so after \r the statements  will be executed

python class topic video