num = input(“Tell me any no. “) num2 = input(“Tell me another no. “) # Type Casting num = int(num) num2 = int(num2) print(“Total is “, num + num2) result = eval(“10+20+30”) print(result) exp = input(“Enter any arithmetic expression: “) result2 = eval(exp) print(result2) Output Learning: a, b, c = 100, 200, 300 print(a,b,c, sep=’ : ‘) print(a,b,c, end=’ – ‘) # Formatted String: # %i –> int # %d –> int # %f –> float # %s –> string a, b, c = 100, 200, 300 print(“a value %d”%a) print(“b value is %d and c is %d”%(b,c)) print(“b value is “, b, “c is “, c) name = ‘langscape’ print(‘Welcome to %s’%name) # Replacement Operator name = ‘Ganesh Pandian’ city = ‘Chennai’ print(‘Hi This is {1}. I am from {0}’.format(city, name)) name = ‘Ganesh Pandian’ city = ‘Chennai’ print(‘Hi This is {}. I am from {}’.format(name, city)) Middle.py name = input(“Enter your name “) #r a j a r a j a n #0 1 2 3 4 5 6 7 8 print(len(name)) mid = len(name)//2 #4 print(name[:mid]+name[mid].upper()+name[mid+1:]) #print(name[0:4]+name[4].upper() + name[5:]) # Control Flow Statements mark = 90 if mark>=90: print(“Very good”) else: print(“Good”) # 2 mark1 = int(input(“Enter your 10th Marks “)) mark2 = int(input(“Enter your 10th Marks “)) if mark1>mark2: print(‘First Person’) elif mark2>mark1: print(‘Second Person’) else: print(“Both got same marks”) # 3: total = int(input(“Enter total “)) if total >400: tamil = int(input(“Enter tamil mark”)) if tamil>80: print(“Very great”) else: print(“Nice “) else: print(“Ok thanks”) Iterative Statements: mind = 43 # Until your guess and mind value are same, continue below steps: #Stop executing below steps when your guess and mind value are same. guess = 0 while guess!=mind: # 0 […]
The post Python – input, output, if else statements appeared first on Payilagam | Java | PYTHON | Selenium| | Android | .NET| Best Training in Chennai.