Tutorials Point, posted on 21st Nov, 2017

Python Number acos() method

#!/usr/bin/python

import math

print "acos(0.64) : ",  math.acos(0.64)
print "acos(0) : ",  math.acos(0)
print "acos(-1) : ",  math.acos(-1)
print "acos(1) : ",  math.acos(1)

Tutorials Point, posted on 21st Nov, 2017

Go if statement

package main

import "fmt"

func main() {
   /* local variable definition */
   var a int = 10
 
   /* check the boolean condition using if statement */
   if( a < 20 ) {
      /* if condition is true then print the following */
      fmt.Printf("a is less than 20\n" )
   }
   fmt.Printf("value of a is : %d\n", a)
}

Tutorials Point, posted on 21st Nov, 2017

Python Number uniform() method

#!/usr/bin/python

import random

print "Random Float uniform(5, 10) : ",  random.uniform(5, 10)
print "Random Float uniform(7, 14) : ",  random.uniform(7, 14)

Tutorials Point, posted on 21st Nov, 2017

Python Number shuffle() method

#!/usr/bin/python

import random

list = [20, 16, 10, 5];
random.shuffle(list)
print "Reshuffled list : ",  list

random.shuffle(list)
print "Reshuffled list : ",  list

Tutorials Point, posted on 21st Nov, 2017

Python Number seed() method

#!/usr/bin/python

import random

random.seed( 10 )
print "Random number with seed 10 : ", random.random()

# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()

# It will generate same random number
random.seed( 10 )
print "Random number with seed 10 : ", random.random()

Tutorials Point, posted on 21st Nov, 2017

Python Number random() method

#!/usr/bin/python

import random

# First random number
print "random() : ", random.random()

# Second random number
print "random() : ", random.random()

Tutorials Point, posted on 21st Nov, 2017

Python Number randrange() method

#!/usr/bin/python

import random

# Select an even number in 100 <= number < 1000
print "randrange(100, 1000, 2) : ", random.randrange(100, 1000, 2)

# Select another number in 100 <= number < 1000
print "randrange(100, 1000, 3) : ", random.randrange(100, 1000, 3)

Tutorials Point, posted on 21st Nov, 2017

Python Number choice() method

#!/usr/bin/python

import random

print "choice([1, 2, 3, 5, 9]) : ", random.choice([1, 2, 3, 5, 9])
print "choice('A String') : ", random.choice('A String')

Tutorials Point, posted on 21st Nov, 2017

Python Number sqrt() method

#!/usr/bin/python

import math   # This will import math module

print "math.sqrt(100) : ", math.sqrt(100)
print "math.sqrt(7) : ", math.sqrt(7)
print "math.sqrt(math.pi) : ", math.sqrt(math.pi)

Tutorials Point, posted on 21st Nov, 2017

Python number round() method

#!/usr/bin/python

print "round(80.23456, 2) : ", round(80.23456, 2)
print "round(100.000056, 3) : ", round(100.000056, 3)
print "round(-100.000056, 3) : ", round(-100.000056, 3)

Advertisements
Loading...