Posts

Showing posts from October, 2017

control structure for for loop

# Program to find the sum of all numbers stored in a list # List of numbers numbers = [6, 5, 3] # variable to store the sum sum = 0 # iterate over the list for val in numbers: sum = sum+val # Output: The sum is 48 print("The sum is", sum)

identity operator

Image
#identity operator a= 20 b= 20 print ("line1", "a=", a, " : ", id(a), "b=", b, ":", id(b)) if (a is b): print("line 2 - a and b have same identity") else: print ("line 2 - a and b do not have same identity") if (id(a) == id(b)): print ("line 3 - a and b have same identitiy") else: print ("line 3 - a and b do not have same identity") b= 30 print ("line 4", "a=", a, ":", id(a), "b=", b, ":", id(b)) if (a is not b): print("line 5 - a and b do not have same identity") else: print("line 5 - a and b have same identity")

membership operators

Image
#membership operator a = 10 b = 20 list1 = [1, 2, 3, 4, 5] fi ( a in list1) : print ("line 1 - a is availabe in the givent list") else: print ("line 1 -  a is not available in the given list") if ( b not in list1): print ("line 2 -  b is not availabe in the givent list") else: print ("line 2 - b is available in the given list") c= b/a if (c in list 1) : print ("line 3 - b is availabe in the givent list") else: print ("line 3 -  b is not available in the given list #membership operator  a = 10  b = 20  list1 = [1, 2, 3, 4, 5] if ( a in list1) : print ("line 1 - a is availabe in the givent list")  else: print ("line 1 -  a is not availabe in the givent list") if ( b not in list1) :   print ("line 2 -  b is not availabe in the givent list") else: print ("line 2 - b is availabe in the givent list")  c= b/a if (c in list1) :  

logic operation

Image
syntax error example else to else:

assignment operator

Image

comparison(comparing)& arithmetic

Image
window r = cdm (to open c window system) open note++ in ' if '      (true) in ' else'   (False)

integer, multiple , input , python string, python list

#an integer assignment counter = 100 miles = 1000.0 #a floating point name = "Jhon" #string print(counter) = 100 print(miles) = 1000 print(name) = Jhon #multiple assignment counter,miles,name = 100, 1000.0, "john" print(counter, miles, name) = 100 1000.0  john #print ("My name is", name) #input names = input("Who are you?") print (names) #input names = input("Who are you?") print ("My name is", names) #python string str= "hello world" print str =  hello world print str[0] = h print #python string str = "hello world!" print (str)   =  hello world! print (str[0]) = h print (str[2:5]) = llo print (str[2:]) =llo world print (str * 2)= hello world!hello world! print (str + "TEST") = hello world! TEST print (str[0:5]) = hello print (str, "TEST") = hello world! TEST #python list list1 = ["abcd", 768, 2.23, 'john', 70.2] tinyli
Image
A data type  in programming is a classification that specifies which type of value a variable has and what type of mathematical, relational or logical operations can be applied to it without causing an error. integer is a data type that is used to classify text and an integer is a data type used to classify whole numbers.   example :  7, 12, 999 code : result:4*78 string Alphanumeric characters example:  hello world, Alice, Bob123 code:  address = "bandar seri begawan  26" Decimal  number with decimal  code: price:1.50 Boolean Representing logical values example:  true, false, yes, no  code: x=2 , y=12 float  Number with a decimal point but longer example: 3.15, 9.06, 00.13 code:  List  The list data type is an not in ordered collection type that stores unique elements. The number of elements in a list data type can vary, but no nulls are allowed. code =  list1 [1,2,3,'a','b']; CREATE TABLE employee ( name char(30),

definition of FORTRAN

FORTRAN is a general-purpose,  imperative   programming language  that is especially suited to  numeric computation  and  scientific computing . Much more into numbers what it is used FORTRAN  (formerly  FORTRAN , derived from "Formula Translation") is a general-purpose, imperative  programming language  that is especially suited to numeric computation and scientific computing. What can Fortran be used for? Yes,  FORTRAN  is  used for  large scale numerical computations. Small scale too, but it faces more competition from things like Mat lab when performance sociability is less important,  FORTRAN  isn't super famous for being intuitive and  convenient