# Hello World program in Python print "Hello World!\n" print("") print ("__________________var_________________") print("") integerEX = 8 longIntEx = 200000000000000000000000L floatEX = 2.2 stringEX = "Hello" booleanEX = True intOne = 7 intTwo = 99 floatOne = 7.9 floatTwo = 9.8 print intTwo / intOne print float(intTwo) / float(intOne) print int() #if then else print("") print ("__________________if then else_________________") print("") hours = 39 wage_per_hour = 10 if hours <= 40: loan = hours * wage_per_hour else: loan_40 = 40 * wage_per_hour over_hours = hours - 40 over_hours_loan = 2 * over_hours * wage_per_hour loan = loan_40 + over_hours_loan print("the calculated loan is", loan) #_____________________________________________ #_____________________________________________ #___________________next______________________ #_____________________________________________ #_____________________________________________ print("") print ("__________________cls1_________________") print("") def main(): print ("Visual Studio Solution Sept 2017") return if __name__ == "__main__": main() #_____________________________________________ #_____________________________________________ #___________________next______________________ #_____________________________________________ #_____________________________________________ print("") print ("__________________if clause_________________") print("") var = 100 if( var == 100) : print "Value of expression is 100" #part 2 #nested if statement var = 49 if var < 200: print "Expression value is less than 200" if var == 150: print "Which is 150" elif var == 100: print "Which is 100" elif var == 50: print "Which is 50" elif var < 50: print "Expression value is less than 50" else: print "Could not find true expression" print "end story" #_____________________________________________ #_____________________________________________ #___________________next______________________ #_____________________________________________ #_____________________________________________ print("") print ("__________________while loop________________") print("") count = 0 while (count < 9): print 'The count is: ', count count = count + 1 print 'end story 2' #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________else Statment with Loops_________________") print("") count = 0 while count < 5: print count, " is thess than 5" count = count + 1 else: print count, " is not less than 5" #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________else Statment with Loops_________________") print("") #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________Lists and various_________________") print("") x = 27 y = 49 z = .271 print int(x) #print ceil(x) print cmp(x,y) List1 = [44, 88, 14] i = List1[1] print(i) List1[0] = 77 i = List1[0] print i #list Comprehensions a = [1, -5, 4, 2, -2, 10] b = [2*x for x in a if x > 0] print b a = ["Dallas", "Los Angeles", "Toronto"] print a[0] print len(a[0]) #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________Random_________________") print("") import random #choicelist [55, 127, 721] dice = random.randrange(1,7) print('Press enter to Roll the Dice', dice) #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________Strings, Etc_________________") print("") #Creating Python string #Creating String using Single Quote Str1 = 'This is a String' print(Str1) #Creating a string using double quotes Str2 = "This is another String but with double quotes" print(Str2) # Creating String using Multiple Single Quotes Str3 = '''This also Work in Python''' print(Str3) #Creating String using Triple Quotes #This is very useful to create multiline text Str4 = """Learn Python Programming At Tutorial Gateway""" print (Str4) #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________Numpy_________________") print("") import numpy as np arr = np.array([1.0, 3.7, 5.3]) print arr #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________SciPy_________________") print("") import scipy.misc as sm n = sm.factorial(4) print "4! = " + str(n) #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________numpy pylab scipy_________________") print("") import numpy as np #from scipy import interpolate import pylab as py x = np.r_[0:10:11j] # also np.linspace(0,10,11) y = np.exp(-x/4)*x #f = interpolate.interpld(x,y) xnew = np.r_[0:10:100j] print x print y print xnew #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________matplotlib numpy matplotlib_________________") print("") import matplotlib.pyplot as plt import numpy as np from matplotlib import interactive interactive(True) x = np.arange(0,5,0.1) print(x) y = np.sin(x) print (y) #plt.plot(x,y) #plt.show #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________pandas_________________") print("") import pandas as pd unames = ['user_id', 'gender', 'age', 'occupation', 'zip'] print unames[:3] #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________list method________________") print("") import time # a very large list of strings strings = ['foo', 'foobar', 'baz', 'qux', 'python', 'Guido Van Rossum'] * 25 print strings y = [x for x in strings if x.startswith('foo')] print y #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________print sine wave to command line________________") print("") import math, time a = 0 while 1: print " "*int(20+20*math.sin(a))+"|" time.sleep(.05) a+=.1 #_____________________________________________ #___________________next______________________ #_____________________________________________ print("") print ("__________________two numerical loops in one________________") print("") #traditional m = range(1,20) print m print("Senior Software Architect")
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more