├── L1 ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.py ├── 5.py ├── 6.py ├── 7.py └── 8.jpg ├── L10 ├── Assignment Operators │ ├── 1.py │ ├── 2.py │ └── 3.py └── Bitwise Operators │ ├── 1.jpg │ ├── 2.py │ ├── 3.py │ ├── 4.jpg │ ├── 5.py │ ├── 6.py │ └── 7.py ├── L11 ├── Logical Operators │ ├── 1.jpg │ ├── Q2.py │ ├── Q3.py │ ├── Q4.py │ └── Q5.py └── Membership Operators │ ├── 1.jpg │ ├── Q2.py │ ├── Q3.py │ └── Q4.py ├── L12 ├── Identity Operators │ ├── 1.jpg │ ├── Q2.py │ ├── Q3.py │ └── Q4.py └── Operators Precedence │ ├── 1.jpg │ ├── Q3.py │ ├── Q4.py │ ├── Q5.py │ └── Q6.py ├── L13 ├── 1.py ├── 2.py └── 3.py ├── L14 ├── 1.jpg ├── Q2.txt ├── Q3.txt ├── Q4.py └── Q5.py ├── L15 ├── 1.jpg ├── 2.py ├── 3.py ├── 4.py └── 5.py ├── L16 ├── Flow Charts │ ├── 1.jpg │ ├── 2.py │ └── 3.jpg └── Pseudo Code │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.py │ └── 4.jpg ├── L17 ├── Algorithmic Problem Solving │ ├── 1.txt │ ├── 2.jpg │ ├── 3.txt │ └── 4.txt ├── Programming Language │ ├── 1.jpg │ └── 2.txt └── Simple Strategies for Developing Algorithms │ └── 1.py ├── L18 ├── 1.py ├── 2.py ├── 3.py └── 4.py ├── L19 ├── 1.jpg ├── 2.py └── 3.jpg ├── L2 ├── 1.py ├── 2-1.jpg ├── 2-2.jpg ├── 2-3.py ├── 2.py └── 3.py ├── L20 ├── 1.py ├── 2.py └── 3.py ├── L21 ├── 1.py ├── 2.py └── 3.py ├── L22 ├── 1.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py └── 6.py ├── L23 ├── 1.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py └── 7.py ├── L24 ├── 1.py └── 2.py ├── L25 └── 1.py ├── L26 └── 1.py ├── L27 ├── 1.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py └── 7.py ├── L28 ├── Introduction to Numbers │ ├── 1.py │ └── 2.py └── Number Type Conversion │ ├── 1.py │ └── 2.py ├── L29 ├── Mathematical Functions │ └── 1.py └── Random Number Functions │ └── 1.jpg ├── L3 ├── 1.py ├── 2.py ├── 3.py ├── 4.py └── 5.py ├── L31 ├── Introduction to Strings │ └── 1.py └── String Operations │ ├── 1.py │ ├── 10.txt │ ├── 11.py │ ├── 12.py │ ├── 13.py │ ├── 14.py │ ├── 15.txt │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py ├── L32 ├── 1.txt ├── 10.py ├── 11.py ├── 12.py ├── 13.py ├── 14.py ├── 15.py ├── 16.py ├── 17.py ├── 18.py ├── 19.py ├── 2.py ├── 3.txt ├── 4.py ├── 5.py ├── 6.py ├── 7.py ├── 8.py └── 9.py ├── L33 ├── 1.txt ├── 2.py ├── 3.py └── 4.py ├── L34 ├── 1.txt ├── 10.py ├── 11.py ├── 12.py ├── 13.py ├── 14.py ├── 15.py ├── 16.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py ├── 7.py ├── 8.py └── 9.py ├── L35 ├── 1.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py └── 6.py ├── L36 ├── 1.py ├── 10.py ├── 11.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py ├── 7.py ├── 8.py └── 9.py ├── L37 ├── Basic Tuples Operations │ ├── 1.jpg │ ├── 10.py │ ├── 11.py │ ├── 12.py │ ├── 2.py │ ├── 3.jpg │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py └── Introduction to Tuples │ ├── 1.jpg │ └── 2.py ├── L38 ├── 1.jpg ├── 2.jpg ├── 3.py ├── 4.py ├── 5.py ├── 6.py ├── 7.py └── 8.py ├── L39 ├── Basic Dictionary Operations │ ├── 1.jpg │ ├── 10.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py └── Introduction to Dictionaries │ ├── 1.jpg │ └── 2.jpg ├── L4 ├── Expressions and Statements │ ├── 1.py │ ├── 2.jpg │ ├── 3.py │ └── 4.jpg └── Indentation │ ├── 1.py │ └── 2.py ├── L40 ├── 1.py ├── 2.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py ├── 7.py ├── 8.py └── 9.py ├── L41 ├── 1.py ├── 2.py └── 3.py ├── L42 ├── Basic Set Operations │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ └── 7.py └── Introduction to Sets │ ├── 1.txt │ ├── 2.txt │ └── 3.py ├── L43 ├── 1.txt ├── 2.py ├── 3.py └── 4.py ├── L44 ├── 1.py ├── 2.py ├── 3.py └── 4.py ├── L45 ├── 1.py └── 2.py ├── L46 └── 1.py ├── L47 ├── 1.jpg ├── 2.jpg ├── 3.py ├── 4.py ├── 5.py ├── 6.jpg ├── 7.py └── 8.py ├── L48 ├── Keyword Arguments │ ├── 1.jpg │ ├── 2.py │ ├── 3.py │ └── 4.py └── Parameters and Arguments │ ├── 1.jpg │ ├── 2.py │ ├── 3.py │ └── 4.py ├── L49 ├── Default Arguments │ ├── 1.py │ ├── 2.py │ ├── 3.jpg │ └── 4.py └── Variable-length Arguments │ ├── 1.jpg │ ├── 2.py │ └── 3.py ├── L5 ├── 2.py ├── 3.jpg └── 5.jpg ├── L50 ├── 1.jpg ├── 2.py ├── 3.py ├── 4.py └── 5.py ├── L51 ├── 1.txt ├── 2.py ├── 3.py └── 4.py ├── L52 ├── Function Composition │ ├── 1.py │ └── 2.py └── Global and Local Variables │ ├── 1.py │ ├── 2.py │ └── 3.py ├── L53 ├── 1.txt ├── 2.txt ├── 3.py ├── 4.py └── 5.py ├── L54 ├── 1.py ├── 2.py └── 3.py ├── L55 ├── 1.txt ├── 2.py └── 3.py ├── L56 ├── 1.py ├── 2.py ├── 3.py ├── 4.py └── 5.txt ├── L57 ├── 1.py ├── 2.py ├── 3.py ├── 4.py └── 5.py ├── L58 ├── 1.txt ├── 2.py ├── 3.py ├── 4.py └── 5.py ├── L59 ├── 1.txt ├── 2.txt ├── 3.txt ├── 4.txt └── 5.py ├── L6 ├── Lists │ ├── 1.py │ └── 2.py ├── Sets │ └── 1.jpg └── Tuples │ ├── 1.jpg │ ├── 2.py │ └── 3.py ├── L60 ├── Installing Packages via PIP │ └── 1.txt └── Introduction to PIP │ └── 1.txt ├── L61 ├── 1.jpg ├── 2.jpg ├── 3.jpg └── 4.jpg ├── L62 ├── 1.jpg ├── 2.jpg ├── 3.jpg ├── 4.py ├── 5.py ├── 6.py ├── 7.py └── 8.py ├── L63 ├── 1.jpg ├── 10.py ├── 11.py ├── 12.py ├── 13.py ├── 2.jpg ├── 3.jpg ├── 4.jpg ├── 5.jpg ├── 6.jpg ├── 7.jpg ├── 8.py └── 9.py ├── L64 ├── 1.py ├── 2.py ├── 3.py └── 4.jpg ├── L65 ├── 1.jpg ├── 2.py ├── 3.py └── 4.py ├── L66 ├── 1.jpg ├── 2.py ├── 3.py └── 4.py ├── L67 ├── 1.jpg ├── 2.jpg ├── 3.py ├── 4.py ├── 5.py ├── 6.jpg ├── 7.py └── 8.py ├── L68 ├── 1.jpg ├── 2.py ├── 3.py └── 4.py ├── L69 ├── 1.jpg ├── 2.jpg ├── 3.py ├── 4.py ├── 5.py └── 6.py ├── L7 ├── Data Type Conversions │ ├── 1.py │ └── 2.py └── Dictionaries │ ├── 1.jpg │ ├── 2.py │ └── 3.py ├── L70 ├── 1.txt ├── 2.txt ├── 3.py ├── 4.txt ├── 5.py └── 6.py ├── L71 ├── 1.txt ├── 2.txt └── 3.txt ├── L72 ├── Handling an Exception │ ├── 1.txt │ ├── 2.py │ ├── 3.py │ └── 4.txt └── Try-finally Clause │ ├── 1.txt │ ├── 2.py │ └── 3.py ├── L73 ├── Raising an Exception │ ├── 1.py │ └── 2.py └── User-Defined Exceptions │ ├── 1.txt │ ├── 2.py │ └── 3.py ├── L74 ├── Dates and Times │ ├── 1.txt │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py ├── Math │ ├── 1.txt │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ └── 8.py ├── Operating System Interface │ ├── 1.txt │ ├── 2.py │ ├── 3.py │ ├── 4.py │ └── 5.py ├── String Pattern Matching │ ├── 1.txt │ ├── 10.py │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.txt │ └── 9.py └── Turtle Graphics │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ └── 6.py ├── L75 ├── Basic concepts of testing │ ├── 1.txt │ ├── 2.txt │ ├── 3.txt │ ├── 4.txt │ └── 5.txt └── Why testing is required │ ├── 1.txt │ └── 2.txt ├── L76 ├── 1.txt ├── 2.txt ├── 3.txt ├── 4.txt ├── 5.txt └── 6.txt ├── L77 ├── Coding Exercises Using Arrays │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ ├── 8.py │ └── 9.py └── Fundamentals Of Arrays In Python Using Array Module │ ├── 1.py │ ├── 2.txt │ ├── 3.py │ ├── 4.py │ ├── 5.py │ ├── 6.py │ ├── 7.py │ └── 8.py ├── L78 ├── 1.py ├── 10.py ├── 11.py ├── 12.py ├── 13.py ├── 14.py ├── 15.py ├── 16.py ├── 17.py ├── 18.py ├── 19.py ├── 2.py ├── 20.py ├── 21.py ├── 22.py ├── 23.py ├── 24.py ├── 3.py ├── 4.py ├── 5.py ├── 6.py ├── 7.py ├── 8.py └── 9.py ├── L8 ├── Basics of Python Programming │ ├── 1.jpg │ └── 2.jpg └── Input and Output Statements │ ├── 1.py │ ├── 2.py │ ├── 3.py │ ├── 4.py │ └── 5.py ├── L9 ├── Arithmetic Operators │ ├── 1.jpg │ ├── 2.py │ ├── 3.py │ ├── 4.py │ ├── 5.py │ └── 6.py └── Comparison Operators │ ├── 1.py │ ├── 2.py │ ├── 3.py │ └── 4.py └── README.md /L1/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L1/1.jpg -------------------------------------------------------------------------------- /L1/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L1/2.jpg -------------------------------------------------------------------------------- /L1/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L1/3.jpg -------------------------------------------------------------------------------- /L1/4.py: -------------------------------------------------------------------------------- 1 | print("Python is Easy") -------------------------------------------------------------------------------- /L1/5.py: -------------------------------------------------------------------------------- 1 | print("Python is not Typhoon") -------------------------------------------------------------------------------- /L1/6.py: -------------------------------------------------------------------------------- 1 | print('Abracadabra'*7) 2 | -------------------------------------------------------------------------------- /L1/7.py: -------------------------------------------------------------------------------- 1 | print("wh" "ere", "the" "re", "is", "a", "will,", "th""ere", "is", "a", "way") -------------------------------------------------------------------------------- /L1/8.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L1/8.jpg -------------------------------------------------------------------------------- /L10/Assignment Operators/1.py: -------------------------------------------------------------------------------- 1 | a=int(input('x: ')) 2 | y=int(input('y: ')) 3 | x=a+y 4 | print(f'x += y: x = {x} and y = {y}') 5 | x=a-y 6 | print(f'x -= y: x = {x} and y = {y}') 7 | x=a*y 8 | print(f'x *= y: x = {x} and y = {y}') 9 | x=a/y 10 | print(f'x /= y: x = {x} and y = {y}') 11 | x=a**y 12 | print(f'x **= y: x = {x} and y = {y}') 13 | x=a//y 14 | print(f'x //= y: x = {x} and y = {y}') 15 | x=a%y 16 | print(f'x %= y: x = {x} and y = {y}') 17 | x=y 18 | print(f'x = y: x = {x} and y = {y}') 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /L10/Assignment Operators/2.py: -------------------------------------------------------------------------------- 1 | # Assignment Operators =, +=, -=, *= 2 | a=int(input('x: ')) 3 | y=int(input('y: ')) 4 | x=y 5 | print(f'x = y: {x}') 6 | x=a+y 7 | print(f'x += y: {x}') 8 | x=a-y 9 | print(f'x -= y: {x}') 10 | x=a*y 11 | print(f'x *= y: {x}') 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /L10/Assignment Operators/3.py: -------------------------------------------------------------------------------- 1 | # Assignment Operators /= , %=, **=, //= 2 | a = int(input("x: ")) 3 | y = int(input("y: ")) 4 | x=a/y 5 | print('x /= y:' , x) 6 | x=a%y 7 | print ('x %= y:' , x) 8 | x=a**y 9 | print ('x **= y:' , x) 10 | x=a//y 11 | print ('x //= y:' , x) -------------------------------------------------------------------------------- /L10/Bitwise Operators/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L10/Bitwise Operators/1.jpg -------------------------------------------------------------------------------- /L10/Bitwise Operators/2.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate bit wise operators >>, << 2 | a=int(input('x: ')) 3 | b=int(input('y: ')) 4 | print(f'{a} >> {b} is {a>>b}') 5 | print(f'{a} << {b} is {a<> {y} is {x>>y}') 4 | print(f'{x} << {y} is {x< 0): 3 | 4 | # convert the given miles into kilometers and print the result 5 | print("kilometers:",miles*1.609) 6 | 7 | else: 8 | print("f") 9 | # print not positive value 10 | 11 | # follow the example given in explanation text -------------------------------------------------------------------------------- /L14/Q5.py: -------------------------------------------------------------------------------- 1 | a=(input("temp with unit: ")) 2 | b=['F','C','f','c'] 3 | x=a[-1] 4 | n=int(a[:-1]) 5 | if x in b: 6 | if x=='C' or x=='c': 7 | cal=(n/(5/9)+32) 8 | cal=round(cal,2) 9 | print(f'{n} C = {cal} F') 10 | elif x=='F' or x=='f': 11 | cal=(5/9)*(n-32) 12 | cal=round(cal,2) 13 | print(f'{n} F = {cal} C') 14 | if x not in b: 15 | print('unrecognized unit:',x) -------------------------------------------------------------------------------- /L15/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L15/1.jpg -------------------------------------------------------------------------------- /L15/2.py: -------------------------------------------------------------------------------- 1 | num1 = int(input("num1: ")) 2 | num2 = int(input("num2: ")) 3 | sum = num1 + num2 4 | print("sum of %d, %d = %d" %(num1, num2, sum)) -------------------------------------------------------------------------------- /L15/3.py: -------------------------------------------------------------------------------- 1 | n=int(input('age: ')) 2 | if n>=18: 3 | print('eligible') 4 | elif n>=0: 5 | print('not eligible') 6 | else: 7 | print('age cannot be negative') -------------------------------------------------------------------------------- /L15/4.py: -------------------------------------------------------------------------------- 1 | # Take an integer input from the user 2 | n=int(input('n: ')) 3 | if(n<51):# write your condition here 4 | for i in range(1, n + 1): 5 | # print the numbers 6 | print(i,end=" ") 7 | #otehrwise print Enter a valid value (1 - 50) 8 | else: 9 | print('enter valid value') -------------------------------------------------------------------------------- /L15/5.py: -------------------------------------------------------------------------------- 1 | def add2Num(): 2 | a=int(input('num1: ')) 3 | b=int(input('num2: ')) 4 | print(f'The sum of {a} and {b} is {a+b}') 5 | # write your logic here 6 | 7 | add2Num() # caling the function add2Num -------------------------------------------------------------------------------- /L16/Flow Charts/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L16/Flow Charts/1.jpg -------------------------------------------------------------------------------- /L16/Flow Charts/2.py: -------------------------------------------------------------------------------- 1 | # write your code here 2 | r=float(input('Enter the radius : ')) 3 | if r>=0: 4 | area=3.14* r *r 5 | print('Area of circle = %f' %area) 6 | else: 7 | print('Enter a positive value upto 100') -------------------------------------------------------------------------------- /L16/Flow Charts/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L16/Flow Charts/3.jpg -------------------------------------------------------------------------------- /L16/Pseudo Code/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L16/Pseudo Code/1.jpg -------------------------------------------------------------------------------- /L16/Pseudo Code/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L16/Pseudo Code/2.jpg -------------------------------------------------------------------------------- /L16/Pseudo Code/3.py: -------------------------------------------------------------------------------- 1 | n=int(input('num: ')) 2 | sum=0 3 | if n>0: 4 | while n>0: 5 | sum=sum +n 6 | n=n-1 7 | print('sum:',sum) 8 | else: 9 | print('enter positive value') 10 | -------------------------------------------------------------------------------- /L16/Pseudo Code/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L16/Pseudo Code/4.jpg -------------------------------------------------------------------------------- /L17/Algorithmic Problem Solving/1.txt: -------------------------------------------------------------------------------- 1 | A programmer need to understand the syntax of the programming language. 2 | 3 | A program written in a particular language has to be translated into machine language. 4 | 5 | It is a time consuming process and difficult to isolate errors in a program written in machine language. -------------------------------------------------------------------------------- /L17/Algorithmic Problem Solving/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L17/Algorithmic Problem Solving/2.jpg -------------------------------------------------------------------------------- /L17/Algorithmic Problem Solving/3.txt: -------------------------------------------------------------------------------- 1 | Interpreters and compilers translate high level language to machine language. 2 | 3 | High level languages are machine independent. -------------------------------------------------------------------------------- /L17/Algorithmic Problem Solving/4.txt: -------------------------------------------------------------------------------- 1 | XML is an example of markup programming language. 2 | 3 | Scripting languages are used to automate frequently executing tasks. 4 | 5 | Functional programming language uses conditional expressions and recursion to perform computation. -------------------------------------------------------------------------------- /L17/Programming Language/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L17/Programming Language/1.jpg -------------------------------------------------------------------------------- /L17/Programming Language/2.txt: -------------------------------------------------------------------------------- 1 | Understanding exactly the inputs the algorithm needs is the fundamental to understanding the problem. 2 | 3 | 4 | Algorithmic design techniques are the cornerstone for designing algorithms for problems. 5 | 6 | 7 | Pseudocode, Flowcharts are methods of expressing an algorithm. 8 | 9 | 10 | An Algorithm should be both time and space efficient besides being simple. -------------------------------------------------------------------------------- /L17/Simple Strategies for Developing Algorithms/1.py: -------------------------------------------------------------------------------- 1 | n=int(input('num: ')) 2 | if n<0: 3 | print('enter a positive value') 4 | else: 5 | def fact(n): 6 | if n==1: 7 | return 1 8 | else: 9 | return n*fact(n-1) 10 | val=fact(n) 11 | print(f'factorial of {n} is: {val}') -------------------------------------------------------------------------------- /L18/1.py: -------------------------------------------------------------------------------- 1 | num=int(input('num: ')) 2 | lis=[] 3 | for i in range(1,(num//2)+1): 4 | if num%i==0: 5 | lis.append(i) 6 | print('factors:',lis) 7 | print('sum:',sum(lis)) 8 | if sum(lis)==num: 9 | print('perfect number') 10 | elif sum(lis)>num: 11 | print('abundant number') 12 | else: 13 | print('deficient number') -------------------------------------------------------------------------------- /L18/2.py: -------------------------------------------------------------------------------- 1 | 2 | def getsum(num): 3 | s=0 4 | for digit in str(num): 5 | s +=int(digit) 6 | return s 7 | num=int(input("num: ")) 8 | a=getsum(num) 9 | print("sum:",a) -------------------------------------------------------------------------------- /L18/3.py: -------------------------------------------------------------------------------- 1 | n=int(input("num: ")) 2 | flag=False 3 | if n>1: 4 | for i in range(2, n): 5 | if (n % i)== 0: 6 | flag = True 7 | break 8 | if flag: 9 | print("not a prime number") 10 | else: 11 | print("prime number") -------------------------------------------------------------------------------- /L18/4.py: -------------------------------------------------------------------------------- 1 | num=int(input("num: ")) 2 | sum=0 3 | temp=num 4 | while(num): 5 | i=1 6 | fact=1 7 | rem=num%10 8 | while(i<=rem): 9 | fact = fact*i 10 | i=i+1 11 | sum=sum+fact 12 | num=num//10 13 | if(sum==temp): 14 | print("strong number") 15 | else: 16 | print("not a strong number") 17 | 18 | -------------------------------------------------------------------------------- /L19/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L19/1.jpg -------------------------------------------------------------------------------- /L19/2.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate simple if statement 2 | num = int(input("num: ")) 3 | if num%3==0 : 4 | print('divisible by 3') 5 | 6 | print('End of program') -------------------------------------------------------------------------------- /L19/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L19/3.jpg -------------------------------------------------------------------------------- /L2/1.py: -------------------------------------------------------------------------------- 1 | print("I am a Python Guru") -------------------------------------------------------------------------------- /L2/2-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L2/2-1.jpg -------------------------------------------------------------------------------- /L2/2-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L2/2-2.jpg -------------------------------------------------------------------------------- /L2/2-3.py: -------------------------------------------------------------------------------- 1 | import keyword 2 | print('and is a keyword :', keyword.iskeyword('and')) 3 | 4 | #Fill in the missing code in the below lines 5 | print('exec is a keyword :',keyword.iskeyword('exec') ) 6 | print('nonlocal is a keyword :',keyword.iskeyword('nonlocal') ) 7 | print('False is a keyword :',keyword.iskeyword('False') ) -------------------------------------------------------------------------------- /L2/2.py: -------------------------------------------------------------------------------- 1 | print("1") 2 | # print("2") 3 | print("3") 4 | # print("4") 5 | print("5") 6 | # print("6") 7 | print("7") 8 | # print("8") 9 | print("9") 10 | # print("10") 11 | print("11") 12 | # print("12") 13 | print("13") -------------------------------------------------------------------------------- /L2/3.py: -------------------------------------------------------------------------------- 1 | def add(a, b): 2 | """Return sum of given arguments.""" 3 | return a + b 4 | 5 | def power(b, e): 6 | """Return the power value. 7 | 8 | b -- is the base 9 | e -- is the exponent 10 | """ 11 | return b ** e 12 | 13 | # print docstring of add method 14 | print(add.__doc__) 15 | 16 | # print docstring of power method 17 | print(power.__doc__) -------------------------------------------------------------------------------- /L20/1.py: -------------------------------------------------------------------------------- 1 | distinction_marks = 75 2 | n=int(input('marks: ')) 3 | if n>distinction_marks: 4 | print('distinction') 5 | else: 6 | print('not distinction') 7 | # write your code here -------------------------------------------------------------------------------- /L20/2.py: -------------------------------------------------------------------------------- 1 | n=int(input('balance: ')) 2 | if n<1000: 3 | print('low') 4 | else: 5 | print('sufficient') -------------------------------------------------------------------------------- /L20/3.py: -------------------------------------------------------------------------------- 1 | # Deductions 2 | Ded_std = 150000 3 | # Request Inputs 4 | Ded_80c = int(input("deduction under 80c: ")) 5 | Ded_80cc = int(input("deduction under 80cc: ")) 6 | Ded_hra = int(input("deduction under HRA: ")) 7 | Ded_med = int(input("deduction under Medical: ")) 8 | Gross_Income = int(input("gross income: ")) 9 | Ded_tot = (Ded_std + Ded_80c + Ded_80cc + Ded_hra + Ded_med) 10 | Tax_Income = Gross_Income - Ded_tot 11 | # Income_Tax=Tax_Income* 0.1 12 | # complete the missing code 13 | if Tax_Income>0: 14 | if Gross_Income <=500000: 15 | Income_tax=Tax_Income*.1 16 | if (Gross_Income <= 1000000) and (Gross_Income > 500000): 17 | Income_tax=25000+((Gross_Income - 500000)*.2) 18 | 19 | if(Gross_Income > 1000000): 20 | Income_tax = 75000+((Gross_Income - 1000000)*.3) 21 | print ("gross income" , Gross_Income) 22 | print ("total deductions =" , Ded_tot) 23 | print ("income tax =" , Income_tax) 24 | else : 25 | print ("hurray..no income tax") -------------------------------------------------------------------------------- /L21/1.py: -------------------------------------------------------------------------------- 1 | print("'0' for exit.") 2 | 3 | # take th input from the user 4 | ch=input("ch: ") 5 | a="a","b","c","d","e",'f','g','h','i','j', 6 | 7 | if ch == '0': 8 | exit() 9 | 10 | elif (ch.isalpha()==True): 11 | print("alphabet") 12 | elif (ch.isalnum()==True): 13 | print("digit") 14 | else: 15 | 16 | print("neither alphabet nor digit") 17 | # write your logic here to find the given input is character or digit -------------------------------------------------------------------------------- /L21/2.py: -------------------------------------------------------------------------------- 1 | num=int(input("num: ")) 2 | if num >0: 3 | print("positive") 4 | elif num==0: 5 | print("zero") 6 | else: 7 | print("negative") -------------------------------------------------------------------------------- /L21/3.py: -------------------------------------------------------------------------------- 1 | year = int(input("year: ")) 2 | if year%400==0 and year%100==0: 3 | print("leap year") 4 | elif year%4==0 and year%100!=0: 5 | print("leap year") 6 | else: 7 | print("not leap year") -------------------------------------------------------------------------------- /L22/1.py: -------------------------------------------------------------------------------- 1 | num=int(input("num: ")) 2 | total=0 3 | 4 | 5 | while num>0: 6 | if num%2==0: 7 | total+=num 8 | num-=1 9 | else: 10 | num=num-1 11 | print("sum:",total) 12 | 13 | # elif num==0: 14 | # print("sum: 0") 15 | # else: 16 | # print("sum") 17 | -------------------------------------------------------------------------------- /L22/2.py: -------------------------------------------------------------------------------- 1 | # Python program to find the sum of integers between 0 and n where n is provided by user 2 | n=int(input("num: ")) 3 | m=0 4 | 5 | # while n>m: 6 | # print("sum:",n*(n+1)//2) 7 | # break 8 | # if n==0: 9 | # print("sum: 0") 10 | if n<0: 11 | while n<0: 12 | m-=n 13 | n+=1 14 | m=-1*m 15 | print("sum:", m) 16 | else: 17 | while n>0: 18 | m+=n 19 | n-=1 20 | print('sum:',m) 21 | #break 22 | # while nn: 15 | break 16 | else: 17 | print(fibbo(i)) -------------------------------------------------------------------------------- /L27/2.py: -------------------------------------------------------------------------------- 1 | x=int(input('x: ')) 2 | y=int(input('y: ')) 3 | def isprime(n): 4 | for i in range(2,int(n**0.5)+1): 5 | if n%i==0: 6 | return False 7 | return True 8 | for i in range(x,y): 9 | if isprime(i): 10 | print(i) -------------------------------------------------------------------------------- /L27/3.py: -------------------------------------------------------------------------------- 1 | n=int(input('n: ')) 2 | l=len(str(n)) 3 | sum=0 4 | a=n*1 5 | while n>0: 6 | temp=n%10 7 | n=n//10 8 | sum+=temp**l 9 | print('sum of powers:',sum) 10 | if sum==a: 11 | print('armstrong number') 12 | else: 13 | print('not armstrong number') -------------------------------------------------------------------------------- /L27/4.py: -------------------------------------------------------------------------------- 1 | a=input('ch: ') 2 | b='aeiouAEIOU' 3 | if a.isalpha(): 4 | if a in b: 5 | print('letter and vowel') 6 | else: 7 | print('letter and consonant') 8 | else: 9 | print('not letter') -------------------------------------------------------------------------------- /L27/5.py: -------------------------------------------------------------------------------- 1 | a,b,c=map(int,input('a,b,c: ').split(',')) 2 | print(max(a,b,c)) -------------------------------------------------------------------------------- /L27/6.py: -------------------------------------------------------------------------------- 1 | n=int(input('n: ')) 2 | val=1 3 | for i in range(1,n+1): 4 | for j in range(i): 5 | print(val,end=" ") 6 | val+=1 7 | print() 8 | -------------------------------------------------------------------------------- /L27/7.py: -------------------------------------------------------------------------------- 1 | n=int(input('rows: ')) 2 | from math import factorial 3 | 4 | for i in range(n): 5 | for j in range(n-i): 6 | print(end=" ") 7 | for j in range(i+1): 8 | print(factorial(i)//(factorial(j)*factorial(i-j)),end=" ") 9 | print() -------------------------------------------------------------------------------- /L28/Introduction to Numbers/1.py: -------------------------------------------------------------------------------- 1 | # find quotient using '/' and '//' like (a/b) and (a//b) 2 | a=int(input('a: ')) 3 | b=int(input('b: ')) 4 | print(f'{a} / {b} = {a/b}') 5 | print(f'{a} // {b} = {a//b}') 6 | print(f'{a} % {b} = {a%b}') 7 | -------------------------------------------------------------------------------- /L28/Introduction to Numbers/2.py: -------------------------------------------------------------------------------- 1 | a=complex(input('c1: ')) 2 | b=complex(input('c2: ')) 3 | print(f"a1 + b2 = {a+b}") 4 | print(f"a1 - b2 = {a-b}") 5 | print(f"a1 * b2 = {a*b}") 6 | print(f"a1 / b2 = {a/b}") -------------------------------------------------------------------------------- /L28/Number Type Conversion/1.py: -------------------------------------------------------------------------------- 1 | # Type Conversion Example 2 | a = '0111110' 3 | i=int(a,2) 4 | d=type(i) 5 | print(f"converting to int: {i} ,data type: {d}") 6 | f=float(i) 7 | d=type(f) 8 | print(f"converting to float: {f} ,data type: {d}") 9 | c=complex(i) 10 | d=type(c) 11 | print(f"converting to complex: {c} ,data type: {d}") -------------------------------------------------------------------------------- /L28/Number Type Conversion/2.py: -------------------------------------------------------------------------------- 1 | x=int(input('x: ')) 2 | print('Decimal:',x, "") 3 | print('Binary:',bin(x), "") 4 | print('Octal:',oct(x), "") 5 | print('Hexadecimal:',hex(x)) 6 | -------------------------------------------------------------------------------- /L29/Mathematical Functions/1.py: -------------------------------------------------------------------------------- 1 | import math 2 | num = float(input("num: ")) 3 | if num - int(num) >=.5: 4 | print ("result:", math.ceil(num)) 5 | else: 6 | print("result:", math.trunc(num)) -------------------------------------------------------------------------------- /L29/Random Number Functions/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L29/Random Number Functions/1.jpg -------------------------------------------------------------------------------- /L3/1.py: -------------------------------------------------------------------------------- 1 | #in the below line, initialize a variable called length with value 18 2 | length=18 3 | 4 | #in the below line, initialize a variable called snake with text "King Cobra" 5 | snake='King Cobra' 6 | 7 | #Make no changes to the below line 8 | print(snake, "can grow up to a length of", length, "feet") -------------------------------------------------------------------------------- /L3/2.py: -------------------------------------------------------------------------------- 1 | value1 = value2 = value3 = "Hello" 2 | print(value1) 3 | print(value2) 4 | print(value3) 5 | # Assign values to variables and print again 6 | value1=99 7 | value2='Hello Python' 8 | value3='Hello World' 9 | print(value1) 10 | print(value2) 11 | print(value3) -------------------------------------------------------------------------------- /L3/3.py: -------------------------------------------------------------------------------- 1 | value1 = value2 = value3 = "Hello" 2 | print(value1) 3 | print(value2) 4 | print(value3) 5 | # Assign values to variables and print again 6 | value1=99 7 | value2='Hello Python' 8 | value3='Hello World' 9 | print(value1) 10 | print(value2) 11 | print(value3) -------------------------------------------------------------------------------- /L3/4.py: -------------------------------------------------------------------------------- 1 | value1 = value2 = value3 = "Hello" 2 | print(value1) 3 | print(value2) 4 | print(value3) 5 | # Assign values to variables and print again 6 | value1=99 7 | value2='Hello Python' 8 | value3='Hello World' 9 | print(value1) 10 | print(value2) 11 | print(value3) -------------------------------------------------------------------------------- /L3/5.py: -------------------------------------------------------------------------------- 1 | value1 = value2 = value3 = "Hello" 2 | print(value1) 3 | print(value2) 4 | print(value3) 5 | # Assign values to variables and print again 6 | value1=99 7 | value2='Hello Python' 8 | value3='Hello World' 9 | print(value1) 10 | print(value2) 11 | print(value3) -------------------------------------------------------------------------------- /L31/Introduction to Strings/1.py: -------------------------------------------------------------------------------- 1 | str1=str(input("str: ")) 2 | print(str1) -------------------------------------------------------------------------------- /L31/String Operations/1.py: -------------------------------------------------------------------------------- 1 | str1 = "This is my first String" 2 | # print the string 3 | print(str1) 4 | # print letter 'f' using Positive Index 5 | print(str1[11]) 6 | # print letter 'S' using Negative Index. 7 | print(str1[-6]) -------------------------------------------------------------------------------- /L31/String Operations/10.txt: -------------------------------------------------------------------------------- 1 | 'z' not in str, returns True -------------------------------------------------------------------------------- /L31/String Operations/11.py: -------------------------------------------------------------------------------- 1 | a=input("str: ") 2 | print(a*4) 3 | print(a[::-1]*3) -------------------------------------------------------------------------------- /L31/String Operations/12.py: -------------------------------------------------------------------------------- 1 | str1=input("str: ") 2 | if len(str1)>=3: 3 | print("result:",str1[:3]*3) 4 | else: 5 | print("result:",str1) -------------------------------------------------------------------------------- /L31/String Operations/13.py: -------------------------------------------------------------------------------- 1 | str1=input("str: ") 2 | num=int(input("num: ")) 3 | print("result:",str1*num) -------------------------------------------------------------------------------- /L31/String Operations/14.py: -------------------------------------------------------------------------------- 1 | str1=input("str: ") 2 | num=int(input("num: ")) 3 | a=str1[:num] 4 | if num<0: 5 | print("num should be positive, less than length of str") 6 | else: 7 | print("result:",a*num) 8 | -------------------------------------------------------------------------------- /L31/String Operations/15.txt: -------------------------------------------------------------------------------- 1 | Strings are Immutable (we can't assign or change the value) -------------------------------------------------------------------------------- /L31/String Operations/2.py: -------------------------------------------------------------------------------- 1 | str = "How are you?" 2 | print("String is", str) 3 | # print 'are' in String using Slicing with Positive Index 4 | print(str[4:7]) 5 | print(str[2:5]) 6 | print(str[-4:-1]) 7 | print(str[-2:-5:-1]) 8 | print(str[-4:]) 9 | # print 'w a' in String using Slicing with Positive Index 10 | # print 'you' in String using Slicing with Negative Index 11 | # print 'uoy' in the string using slicing and Negative indexes and negative step 12 | # print 'you?' in String using Slicing with Negative Index -------------------------------------------------------------------------------- /L31/String Operations/3.py: -------------------------------------------------------------------------------- 1 | # Type Content here... 2 | inp=str(input("input: ")) 3 | if len(inp)>4: 4 | 5 | print(f"output: {inp[:2]}{inp[-2:]}") 6 | else: 7 | print(f"output: {inp[:2]}") -------------------------------------------------------------------------------- /L31/String Operations/4.py: -------------------------------------------------------------------------------- 1 | str1=str(input("str: ")) 2 | print(f'output: {str1[1:-1]}') -------------------------------------------------------------------------------- /L31/String Operations/5.py: -------------------------------------------------------------------------------- 1 | str1=input("str: ") 2 | # str1[0],str1[-1]=str1[-1],str1[0] 3 | # a=str1[::-1] 4 | # print(a) 5 | # b=a[1:5] 6 | # l=b[::-1] 7 | # print(l) 8 | # # c=b[::-1] 9 | if len(str1)==0: 10 | print("null") 11 | elif len(str1)==1: 12 | print(str1) 13 | else: 14 | val=str1[::-1] 15 | res=str(val[0]+val[1:-1][::-1]+val[-1]) 16 | print("output:",res) -------------------------------------------------------------------------------- /L31/String Operations/6.py: -------------------------------------------------------------------------------- 1 | str1=input("str1: ") 2 | str2=input("str2: ") 3 | print(f'result: {str1+str2+str2+str1}') -------------------------------------------------------------------------------- /L31/String Operations/7.py: -------------------------------------------------------------------------------- 1 | s=input("str: ") 2 | n=int(input("num: ")) 3 | if n>=len(s) or n<0: 4 | print("num should be positive, less than the length of str") 5 | # elif 6 | else: 7 | print(f"output:",s[:n]+s[n+1:]) 8 | -------------------------------------------------------------------------------- /L31/String Operations/8.py: -------------------------------------------------------------------------------- 1 | str1=input("str1: ") 2 | str2=input("str2: ") 3 | print(str1+' '+str2) -------------------------------------------------------------------------------- /L31/String Operations/9.py: -------------------------------------------------------------------------------- 1 | str1=input("str1: ") 2 | str2=input("str2: ") 3 | if (len(str1)==1) and (len(str2)==1): 4 | print("null") 5 | else: 6 | 7 | print('output:',str1[1:]+str2[1:] ) -------------------------------------------------------------------------------- /L32/1.txt: -------------------------------------------------------------------------------- 1 | In Python, we can convert strings of Uppercase letters into lower case and lower case to upper case using swapcase() method. 2 | 3 | 4 | print('python is simple'.title()) gives output like Python Is Simple. 5 | 6 | 7 | print('20.3'.isnumeric()) it returns output as False. -------------------------------------------------------------------------------- /L32/10.py: -------------------------------------------------------------------------------- 1 | #Program to remove punctuation marks from a string 2 | import string 3 | punctuations = string.punctuation 4 | result = " " 5 | str = "List - []\n tuple - ()\n Dictionary - {}\n Comment - #\n Multiply - *\n not - !\n and - &\n or - |\n format specifier - %\n String - " " $ @ ; : ' / + = " 6 | 7 | 8 | #write your code here for removing punctuation 9 | for i in str: 10 | if i not in punctuations: 11 | result = result + i 12 | 13 | 14 | 15 | print("Set of punctuations in string.punctuation is:", punctuations) # print punctuations 16 | # else: 17 | print("String after removing all Punctuation's is:", result) # print result here -------------------------------------------------------------------------------- /L32/11.py: -------------------------------------------------------------------------------- 1 | str1=input("str1: ") 2 | str2=input("str2: ") 3 | print("count:",str1.count(str2)) -------------------------------------------------------------------------------- /L32/12.py: -------------------------------------------------------------------------------- 1 | # write a program to print the every character in the given string twice' 2 | str1=input("str: ") 3 | # for s in str1: 4 | def string1(s): 5 | double=''.join([i+i for i in s]) 6 | return double 7 | # res="" 8 | # for i in str1: 9 | # res+=i*2 10 | # return res 11 | print("result: ",string1(str1)) -------------------------------------------------------------------------------- /L32/13.py: -------------------------------------------------------------------------------- 1 | str1=str(input("str: ")) 2 | a=int(len(str1)//2)+1 3 | # print(a) 4 | # for i in range(a+1): 5 | # print(str1(i)) 6 | # a=len() 7 | 8 | if len(str1)%2==0: 9 | print("first half str of even length:",(str1[:len(str1)//2])) 10 | else: 11 | 12 | print("second half str of odd length:",(str1[a:])) -------------------------------------------------------------------------------- /L32/14.py: -------------------------------------------------------------------------------- 1 | #Write your code her 2 | str1=input("str: ") 3 | if str1=="": 4 | print("null") 5 | print("first: ") 6 | print("second: ") 7 | print("original: ") 8 | elif len(str1)==1: 9 | print(str1) 10 | print("first:",str1) 11 | print("second: ") 12 | print("original:",str1) 13 | else: 14 | # print(str1) 15 | print("first:",str1[::2]) 16 | print("second:",str1[1::2]) 17 | print("original:",str1) 18 | -------------------------------------------------------------------------------- /L32/15.py: -------------------------------------------------------------------------------- 1 | # Write your code here 2 | str1=input("str: ") 3 | tmp="" 4 | for i in range(1,len(str1)+1): 5 | tmp+=str1[:i] 6 | # print(tmp) 7 | # for j in tmp: 8 | print("incremental order:",tmp) -------------------------------------------------------------------------------- /L32/16.py: -------------------------------------------------------------------------------- 1 | # Write your code here 2 | str1=input("str with hyphens: ") 3 | res='' 4 | for i in str1.split('-'): 5 | res+=i 6 | print(res) -------------------------------------------------------------------------------- /L32/17.py: -------------------------------------------------------------------------------- 1 | import string 2 | print("Character\t ASCII Code") 3 | for i in range(97,123): 4 | print(f'{chr(i)} {i}') 5 | for j in range(65,91): 6 | print(f'{chr(j)} {j}') -------------------------------------------------------------------------------- /L32/18.py: -------------------------------------------------------------------------------- 1 | # Get the Input string 2 | from collections import Counter 3 | k=input("str: ") 4 | 5 | # Sort the string 6 | 7 | k=sorted(k) 8 | # Take empty List 9 | l=[] 10 | 11 | # For each character in the input 12 | k=Counter(k) 13 | 14 | # check whether printed or not 15 | for i in k: 16 | print("'"+str(i)+f"'\t{k[i]}") 17 | 18 | # print char and count 19 | print(list(k)) 20 | 21 | # add to printed list -------------------------------------------------------------------------------- /L32/19.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | str1=input("str: ") 3 | b=Counter(str1) 4 | for i in b: 5 | print(f'{(i)} {b[i]}') -------------------------------------------------------------------------------- /L32/2.py: -------------------------------------------------------------------------------- 1 | str1 = input("str: ") 2 | # make string str1 into all upper case letters. 3 | st=str1.upper() 4 | print(st) 5 | # make string str1 into only every word of first letter into upper case. 6 | st1=str1.title() 7 | print(st1) 8 | 9 | # split every word of a string str1 with space. 10 | at2=str1.split(' ') 11 | print(at2) 12 | # fill str1 with '%' special characer 25 width 13 | print(str1.center(25,'%')) 14 | # make string str1 into small letters. 15 | print(str1.lower()) 16 | str2 = '@' 17 | # join string str2 with str1 18 | a=str2.join(str1) 19 | print(a) 20 | 21 | # replace a word 'Strings' with 'Tuples'. 22 | print(str1.replace("Strings" ,"Tuples")) -------------------------------------------------------------------------------- /L32/3.txt: -------------------------------------------------------------------------------- 1 | print("\nhello") prints the output hello on a new line 2 | 3 | str = '123', the below code is correct to convert string into int. print(int(str)) # 123. 4 | 5 | 6 | str = "hello world", print(str.isalnum()) returns False. -------------------------------------------------------------------------------- /L32/4.py: -------------------------------------------------------------------------------- 1 | str1=input("str1: ") 2 | str2=input("str2: ") 3 | print((str1*3)+str2) -------------------------------------------------------------------------------- /L32/5.py: -------------------------------------------------------------------------------- 1 | # Type Content here... 2 | print("Python provides built-in libraries\nUsing Python we can implement more and more applications\n\tPython is Robust") -------------------------------------------------------------------------------- /L32/6.py: -------------------------------------------------------------------------------- 1 | #use len() to find length of String 2 | str1=input("str1: ") 3 | str2=input("str2: ") 4 | # if len(str1)>len(str2): 5 | # print(str2+str1+str2) 6 | if len(str1)==len(str2): 7 | print("strings are same length") 8 | else: 9 | if len(str1)>len(str2): 10 | print(str2+str1+str2) 11 | else: 12 | print(str1+str2+str1) -------------------------------------------------------------------------------- /L32/7.py: -------------------------------------------------------------------------------- 1 | 2 | str1=input("str: ") 3 | a=str1.startswith('Python') 4 | b=str1.endswith('programming') 5 | if str1.startswith('Python') and str1.endswith('programming'): 6 | print("valid") 7 | else: 8 | print("invalid") 9 | print("character with min val:",min(str1)) 10 | print("character with max val:",max(str1)) -------------------------------------------------------------------------------- /L32/8.py: -------------------------------------------------------------------------------- 1 | # Note: Python and python are different. 2 | a="Python" 3 | str1=input("str: ") 4 | if str1=="Python": 5 | print("str is:",str1) 6 | else: 7 | print("str after adding 'Python':",a+' '+str1) -------------------------------------------------------------------------------- /L32/9.py: -------------------------------------------------------------------------------- 1 | # Take a string input form the user 2 | 3 | # Reverse the string using slicing operator 4 | str1=input("str: ") 5 | print(str1[::-1]) -------------------------------------------------------------------------------- /L33/1.txt: -------------------------------------------------------------------------------- 1 | Lists are ordered and can contain other lists as elements. -------------------------------------------------------------------------------- /L33/2.py: -------------------------------------------------------------------------------- 1 | data = input("data: ") 2 | 3 | # print type of input data here 4 | print("type of data:",type(data)) 5 | 6 | list1 = data.split() # split() is used to convert a string into list 7 | 8 | # print list1 9 | print("list:",list1) 10 | # print type of list1 11 | print("type of list:",type(list1)) -------------------------------------------------------------------------------- /L33/3.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(",") 2 | print('list:',data) 3 | print('type of list:',type(data)) 4 | -------------------------------------------------------------------------------- /L33/4.py: -------------------------------------------------------------------------------- 1 | list1 = ["Python", 100, "Lists", 8.8,'A', "Program"] 2 | # print the list1 items 3 | # for i in list1: 4 | print("List1 contains:",list1) 5 | print("Type of list1:",type(list1)) 6 | 7 | # print the type of list1 -------------------------------------------------------------------------------- /L34/1.txt: -------------------------------------------------------------------------------- 1 | l1 = [1, 20, 30, 40] index of l1 starts from 0. -------------------------------------------------------------------------------- /L34/10.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(",") 2 | print("before updation:",data) 3 | index=int(input("index: ")) 4 | if indexlen(data)*-1: 5 | tmp=input("element: ") 6 | data[index]=tmp 7 | print('after updation:',data) 8 | else: 9 | print('invalid') 10 | -------------------------------------------------------------------------------- /L34/11.py: -------------------------------------------------------------------------------- 1 | data=list(map(int,input("data: ").split(","))) 2 | print(data) 3 | print("largest among first, last elements:",max(data[0],data[-1])) -------------------------------------------------------------------------------- /L34/12.py: -------------------------------------------------------------------------------- 1 | a=list(input("data: ").split(',')) 2 | b=a 3 | print('list1 is list2:',a is b) 4 | print('list2 is list1:',b is a) 5 | i=int(input("index: ")) 6 | if i=len(a)*-1: 7 | val=input('element: ') 8 | a[i]=val 9 | print('list1 is list2:',a is b) 10 | print('list2 is list1:',b is a) 11 | else: 12 | print('enter valid index') -------------------------------------------------------------------------------- /L34/13.py: -------------------------------------------------------------------------------- 1 | a=list(input("data: ").split(',')) 2 | b=a 3 | print('list1 is list2:',a is b) 4 | print('list2 is list1:',b is a) 5 | i=int(input("index: ")) 6 | if i=len(a)*-1: 7 | val=input('element: ') 8 | a[i]=val 9 | print('list1 is list2:',a is b) 10 | print('list2 is list1:',b is a) 11 | else: 12 | print('enter valid index') -------------------------------------------------------------------------------- /L34/14.py: -------------------------------------------------------------------------------- 1 | data=list(input("data1: ").split(',')) 2 | data2=list(input("data2: ").split(',')) 3 | if data[0]==data2[0] or data[-1]==data2[-1]: 4 | print("True") 5 | else: 6 | print("False") -------------------------------------------------------------------------------- /L34/15.py: -------------------------------------------------------------------------------- 1 | #del 2 | dlist = ['red', 'orange', 'blue', 'green', 'yellow', 'cyan'] 3 | print("dlist =", dlist) 4 | print("del dlist[5]") 5 | #delete element 5 6 | del dlist[5] 7 | print("dlist =",dlist) 8 | # print the result 9 | print("del dlist[2:]") 10 | del dlist[2:] 11 | print("dlist =", dlist) 12 | print("del dlist") 13 | del dlist 14 | 15 | #remove 16 | remlist = ['red', 'orange', 'blue', 'green', 'yellow', 'cyan'] 17 | print("remlist =", remlist) 18 | print("remlist.remove('green')") 19 | remlist.remove("green") 20 | print("remlist =",remlist) 21 | # remove green from the list and print the list 22 | 23 | 24 | #pop 25 | plist = ['red', 'orange', 'blue', 'green', 'yellow', 'cyan'] 26 | print("plist =", plist) 27 | print("elem = plist.pop(2)") 28 | 29 | # remove element at index 2 30 | 31 | print("element popped & removed :", plist[2]) 32 | plist.remove(plist[2]) 33 | 34 | print("plist =",plist ) 35 | print("elem = plist.pop()") 36 | # elem=plist.pop(2) 37 | 38 | # remove last element 39 | # plist.remove(plist1[-1]) 40 | print("element popped & removed :", plist[-1]) 41 | plist.remove(plist[-1]) 42 | print("plist =", plist) 43 | print("plist.clear()") 44 | plist.clear() 45 | print("plist =", plist) -------------------------------------------------------------------------------- /L34/16.py: -------------------------------------------------------------------------------- 1 | 2 | data =list(input("data: ").split(',')) 3 | print(data) 4 | # res=[*set(data)] 5 | # b=sorted(res) 6 | a=[i for j, i in enumerate(data) if i not in data[:j]] 7 | print("after removing duplicates:",a) -------------------------------------------------------------------------------- /L34/2.py: -------------------------------------------------------------------------------- 1 | # a=[] 2 | b=input("data: ").split(',') 3 | # a.append(b) 4 | print('list:',b) 5 | a=int(input('index: ')) 6 | try: 7 | print('element:',b[a]) 8 | except: 9 | 10 | print('invalid') -------------------------------------------------------------------------------- /L34/3.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(',') 2 | elem=input("element: ") 3 | if elem in data: 4 | print("True") 5 | else: 6 | print("False") -------------------------------------------------------------------------------- /L34/4.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(',') 2 | print(f'first, last elements: {data[0]} {data[-1]}') -------------------------------------------------------------------------------- /L34/5.py: -------------------------------------------------------------------------------- 1 | a = [9, 8, 7, 6, 5, 4] 2 | 3 | # write your code here 4 | print("a =",a) 5 | print("a[0:3] =",a[0:3]) 6 | print("a[:4] =",a[:4]) 7 | print("a[:] =",a[:]) 8 | print("a[2:2] =",a[2:2]) 9 | print("a[0:6:2] =",a[0:6:2]) 10 | print("a[-3:] =",a[-3:]) 11 | print("a[:-3] =",a[:-3]) -------------------------------------------------------------------------------- /L34/6.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(',') 2 | if data[0]=='3' or data[-1]=='3': 3 | print("True") 4 | else: 5 | print("False") -------------------------------------------------------------------------------- /L34/7.py: -------------------------------------------------------------------------------- 1 | data=input("data1: ").split(",") 2 | data1=input("data2: ").split(",") 3 | num=int(input("num: ")) 4 | tmp=data+data1 5 | data=data*num 6 | data1=data1*num 7 | print(data) 8 | print(data1) 9 | print('extending list1 with list2:',tmp) -------------------------------------------------------------------------------- /L34/8.py: -------------------------------------------------------------------------------- 1 | data1=input("data1: ").split(",") 2 | data2=input("data2: ").split(",") 3 | # if (data1==data2): 4 | print("is equal:",data1==data2) 5 | # eif data1!=data2: 6 | print("is not equal:",data1!=data2) -------------------------------------------------------------------------------- /L34/9.py: -------------------------------------------------------------------------------- 1 | data=input("data: ").split(",") 2 | if data[0]==data[-1]: 3 | print("equal") 4 | else: 5 | print("not equal") -------------------------------------------------------------------------------- /L35/1.py: -------------------------------------------------------------------------------- 1 | data=list(map(int,input("data: ").split(','))) 2 | print("length:",len(data)) 3 | print("list enumerate:",list(enumerate(data))) 4 | print("max:",max(data)) 5 | print("min:",min(data)) 6 | print("list:",sorted(data)) -------------------------------------------------------------------------------- /L35/2.py: -------------------------------------------------------------------------------- 1 | data=list(map(int,input("data: ").split(','))) 2 | # data=int(data) 3 | print("min:",min(data)) 4 | print("max:",max(data)) 5 | print("difference:",max(data)-min(data)) -------------------------------------------------------------------------------- /L35/3.py: -------------------------------------------------------------------------------- 1 | data=list(map(int,input("data: ").split(','))) 2 | # for i in data: 3 | # i+=data[i] 4 | print("sum:",sum(data)) -------------------------------------------------------------------------------- /L35/4.py: -------------------------------------------------------------------------------- 1 | data=list(map(int,input("data: ").split(','))) 2 | print("list:",data) 3 | print("sum:",sum(data)) 4 | res=[i**2 for i in data] 5 | print("squares:",res) 6 | print("sum of squares:",sum(res)) -------------------------------------------------------------------------------- /L35/5.py: -------------------------------------------------------------------------------- 1 | list1=list(input("data1: ").split(',')) 2 | list2=list(input("data2: ").split(',')) 3 | if len(list1)==len(list2): 4 | res="{" 5 | for i in range(len(list1)): 6 | res+=("'"+str(list1[i])+"'") 7 | res+=":" 8 | res+=("'"+list2[i]+"'") 9 | res+=',' 10 | res=res[:-1] 11 | res+='}' 12 | print(res) 13 | # k="}" 14 | # for i in list1: 15 | # for j in list2: 16 | # print(f'{list[i]}{i:j}{k}') 17 | # for key in list1: 18 | # for value in list2: 19 | # res[key]=value 20 | # list2.remove(value) 21 | # break 22 | # print((res)) 23 | else: 24 | print("lists are different lengths") 25 | -------------------------------------------------------------------------------- /L35/6.py: -------------------------------------------------------------------------------- 1 | # import numpy as np 2 | data1=list(map(int,input("data1: ").split(','))) 3 | data2=list(map(int,input("data2: ").split(','))) 4 | # def diff(data1,data2): 5 | # res=[i for i in data1+data2 if i not in data1 or i not in data2] 6 | # return res 7 | if len(data1)==len(data2): 8 | sub=list() 9 | for i, j in zip(data1,data2): 10 | res=i-j 11 | sub.append(res) 12 | print(sub) 13 | 14 | else: 15 | print("lists are different lengths") -------------------------------------------------------------------------------- /L36/1.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | ele=input('element: ') 3 | a.append(ele) 4 | print('after append:',a) 5 | b=input('data2: ').split(',') 6 | # print('data2:',b) 7 | a.append(b) 8 | print('after append:',a) 9 | a.extend(b) 10 | print('after extending:',a) 11 | 12 | -------------------------------------------------------------------------------- /L36/10.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | a=list(input('Please enter a sentence: ').lower()) 3 | b=Counter(a) 4 | c=list(set(a.copy())) 5 | c.sort() 6 | for i in c: 7 | if i.isalpha(): 8 | print(str(i)+" "+str(b[i])) -------------------------------------------------------------------------------- /L36/11.py: -------------------------------------------------------------------------------- 1 | a=int(input('size: ')) 2 | b=[] 3 | while a>0: 4 | e=input('element: ') 5 | b.append(e) 6 | a-=1 7 | print('list:',b) -------------------------------------------------------------------------------- /L36/2.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | a.reverse() 3 | print('reverse:',a) -------------------------------------------------------------------------------- /L36/3.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | el=input('element: ') 3 | v=a.count(el) 4 | print(str(el) +" occurs "+str(v)+" times") -------------------------------------------------------------------------------- /L36/4.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | sum=0 3 | for i in a: 4 | sum+=i 5 | print('sum:',sum) -------------------------------------------------------------------------------- /L36/5.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | print('list:',a) 3 | n=int(input('num: ')) 4 | for i in range(len(a)): 5 | if a[i]==n: 6 | if a[i+1]==n: 7 | print(True) 8 | break 9 | else: 10 | print(False) -------------------------------------------------------------------------------- /L36/6.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | b=input('seq of elements: ').split(',') 3 | for i in b: 4 | if i not in a: 5 | print('does not exist') 6 | break 7 | else: 8 | print('exist') -------------------------------------------------------------------------------- /L36/7.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | b=[a[i] for i in range(len(a)) if i%2!=0] 3 | print('odd index elements:',b) -------------------------------------------------------------------------------- /L36/8.py: -------------------------------------------------------------------------------- 1 | sd=input('Please enter A in upper case: ') 2 | df=input('Please enter A in lower case: ') 3 | i=ord('A') 4 | j=ord('a') 5 | a=[] 6 | for k in range(26): 7 | a.append(chr(i)) 8 | a.append(chr(j)) 9 | i+=1 10 | j+=1 11 | print(a) -------------------------------------------------------------------------------- /L36/9.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | 3 | l=sorted(a) 4 | if l==a: 5 | print('True') 6 | else: 7 | print('False') -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L37/Basic Tuples Operations/1.jpg -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/10.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ') 2 | b=input('data2: ') 3 | if a==b: 4 | print(True) 5 | else: 6 | print(False) -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/11.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | ele=input('element: ') 3 | if ele in a: 4 | print('before deletion:',tuple(a)) 5 | a.remove(ele) 6 | print('after deletion:',tuple(a)) 7 | else: 8 | print('enter existed element') -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/12.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | s=int(input('start index: ')) 3 | e=int(input('end index: ')) 4 | if slen(a)*-1 and e>len(a)*-1): 5 | print('tuple in given range:',tuple(a[s:e])) 6 | else: 7 | print('enter valid index') -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/2.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('list:',a) 3 | print('tuple:',tuple(a)) 4 | i=int(input('index: ')) 5 | if i len(a)*-1: 6 | print('element:',a[i]) 7 | else: 8 | print('enter valid index') 9 | -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L37/Basic Tuples Operations/3.jpg -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/4.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | val=int(input('value: ')) 3 | print(f"tuple * {val} = {tuple(a*val)}") 4 | b=input('data2: ').split(',') 5 | print(f'concatenation: {tuple(a+b)}') -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/5.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('tuple:',tuple(a)) 3 | val=input('value: ') 4 | print(val in a) -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/6.py: -------------------------------------------------------------------------------- 1 | mytup = ('a', 'b', 'c', 'd') 2 | print("mytup =", mytup) 3 | mytup=('a','b','c','d',[1,2,3]) 4 | # add elements to the mytup 5 | print("mytup =", mytup) 6 | print("mytup[4][1] = 4") 7 | 8 | # write your code here 9 | mytup[4][1]=4 10 | print("mytup =", mytup) -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/7.py: -------------------------------------------------------------------------------- 1 | mytup = ('a', 'b', 'c', 'd', [1, 2, 3]) 2 | print("mytup =", mytup) 3 | print("del mytup[4][2]") 4 | 5 | # delele the element 3 from the mytup 6 | del mytup[4][-1] 7 | print("mytup =", mytup) 8 | print("del mytup[4] will give TypeError") -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/8.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | ind=int(input('index: ')) 3 | # val=input() 4 | if ind=len(a)*-1: 5 | val=input('value: ') 6 | a[ind]=val 7 | print('tuple:',tuple(a)) 8 | else: 9 | print('enter valid index') 10 | -------------------------------------------------------------------------------- /L37/Basic Tuples Operations/9.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('tuple:',tuple(a)) 3 | ind=int(input('index: ')) 4 | if indlen(a)*-1: 5 | a.pop(ind) 6 | print('after removing:',tuple(a)) 7 | else: 8 | print('enter valid index') -------------------------------------------------------------------------------- /L37/Introduction to Tuples/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L37/Introduction to Tuples/1.jpg -------------------------------------------------------------------------------- /L37/Introduction to Tuples/2.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('list:',a) 3 | print('tuple:',tuple(a)) -------------------------------------------------------------------------------- /L38/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L38/1.jpg -------------------------------------------------------------------------------- /L38/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L38/2.jpg -------------------------------------------------------------------------------- /L38/3.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('length:',len(a)) -------------------------------------------------------------------------------- /L38/4.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('tuple:',tuple(a)) 3 | e=input('element: ') 4 | if e in a: 5 | print('existed '+str(a.count(e))+ " times") 6 | else: 7 | print('enter valid element') -------------------------------------------------------------------------------- /L38/5.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | print('tuple:',tuple(a)) 3 | print('sum:',sum(a)) -------------------------------------------------------------------------------- /L38/6.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | print('max:',max(a)) -------------------------------------------------------------------------------- /L38/7.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data: ').split(','))) 2 | print('min:',min(a)) -------------------------------------------------------------------------------- /L38/8.py: -------------------------------------------------------------------------------- 1 | a=input('data: ').split(',') 2 | print('tuple:',tuple(a)) 3 | e=input('element: ') 4 | 5 | if e in a: 6 | print('index:',a.index(e)) 7 | else: 8 | print('enter an element that exists in tuple') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L39/Basic Dictionary Operations/1.jpg -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/10.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | key=input('key: ') 4 | c=dict(sorted(zip(a,b))) 5 | if key in c: 6 | val=input('value: ') 7 | val=c[key]=val 8 | # print('value:',val) 9 | print('sorted dictionary:',list(sorted(c.items()))) 10 | else: 11 | print('key does not exist') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/2.py: -------------------------------------------------------------------------------- 1 | # Write your code here 2 | a=input('data1: ').split(',') 3 | b=input('data2: ').split(',') 4 | print('list1:',a) 5 | print('list2:',b) 6 | print('dictionary:',sorted(list(zip(a,b)))) -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/3.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | if len(a)==len(b): 4 | print(sorted(list(zip(a,b)))) 5 | else: 6 | print('length should be equal') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/4.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | key=input('key: ') 4 | dic=dict(zip(a,b)) 5 | if key in dic: 6 | print('value:',dic[key]) 7 | else: 8 | print('value: None') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/5.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | key=input('key: ') 4 | dic=dict(zip(a,b)) 5 | if key in dic: 6 | print('True') 7 | else: 8 | print('False') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/6.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | dic=dict(sorted(zip(a,b))) 4 | for i,j in dic.items(): 5 | print(i,j) -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/7.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | for i,j in dict(sorted(zip(a,b))).items(): 4 | print(str(i)+' -> '+str(j)) -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/8.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | c=dict(sorted(zip(a,b))) 4 | key=input('key: ') 5 | if key in c: 6 | val=c.pop(key) 7 | print('value:',val) 8 | print('dictionary:',list(c.items())) 9 | else: 10 | print('key does not exist') -------------------------------------------------------------------------------- /L39/Basic Dictionary Operations/9.py: -------------------------------------------------------------------------------- 1 | data1 = input("data1: ") 2 | data2 = input("data2: ") 3 | list1 = data1.split(",") 4 | list2 = data2.split(",") 5 | dict1 = dict(zip(list1, list2)) 6 | a=dict1.keys() 7 | b=dict1.values() 8 | 9 | print('max:',max(b)) 10 | print('min:',min(b)) -------------------------------------------------------------------------------- /L39/Introduction to Dictionaries/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L39/Introduction to Dictionaries/1.jpg -------------------------------------------------------------------------------- /L39/Introduction to Dictionaries/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L39/Introduction to Dictionaries/2.jpg -------------------------------------------------------------------------------- /L4/Expressions and Statements/1.py: -------------------------------------------------------------------------------- 1 | number1 = 20.50 2 | number2 = 38.25 3 | # Print the multiplication of number1 and number2 using * operator. 4 | print(number1 * number2) 5 | string1 = "Amazon" 6 | string2 = "River" 7 | # Print the concatenated value of string1 and string2 using + operator. 8 | print(string1 + string2) -------------------------------------------------------------------------------- /L4/Expressions and Statements/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L4/Expressions and Statements/2.jpg -------------------------------------------------------------------------------- /L4/Expressions and Statements/3.py: -------------------------------------------------------------------------------- 1 | message='Welcome to Python' 2 | print(message) 3 | number=45 4 | number+=5 5 | print(number) -------------------------------------------------------------------------------- /L4/Expressions and Statements/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L4/Expressions and Statements/4.jpg -------------------------------------------------------------------------------- /L4/Indentation/1.py: -------------------------------------------------------------------------------- 1 | if 100.0 > 10.0: 2 | print("Small Value:", 10.0) 3 | 4 | else: 5 | print("Large Value:", 100.0) -------------------------------------------------------------------------------- /L4/Indentation/2.py: -------------------------------------------------------------------------------- 1 | print("Hello Python") -------------------------------------------------------------------------------- /L40/1.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | c=dict(sorted(zip(a,b))) 4 | print('all(dict1):',all(c)) 5 | print('any(dict1):',any(c)) 6 | print('len(dict1):',len(a)) 7 | print('sorted(dict1):',list(c.keys())) 8 | print('key,value of dictionary: ') 9 | for i,j in c.items(): 10 | print(str(i)+":"+str(j)) 11 | -------------------------------------------------------------------------------- /L40/2.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | dic=dict(sorted(zip(a,b))) 4 | print('before exchange:',list(dic.items())) 5 | di={x:y for y,x in dic.items()} 6 | print('after exchange:',list(sorted(di.items()))) -------------------------------------------------------------------------------- /L40/3.py: -------------------------------------------------------------------------------- 1 | 2 | troupe = {('Cleese', 'John') : [1, 2, 3], 3 | ('Chapman', 'Graham') : [4, 5, 6], 4 | ('Idle', 'Eric') : [7, 8, 9], 5 | ('Jones', 'Terry') : [10, 11, 12], 6 | ('Gilliam', 'Terry') : [13, 14, 15, 16, 17, 18], 7 | ('Palin', 'Michael') : [19, 20]} 8 | for i,j in sorted(troupe.items()): 9 | a=(list(i)) 10 | print(f"{a[1]} {a[0]} {j}") 11 | -------------------------------------------------------------------------------- /L40/4.py: -------------------------------------------------------------------------------- 1 | #Program to combine two dictionaries 2 | data1 = input("Enter integer elements separated by ,(comma) for keys of dict1: ") 3 | data2 = input("Enter integer elements separated by ,(comma) for values of dict1: ") 4 | list1 = data1.split(",") 5 | list2 = data2.split(",") 6 | for i in range(len(list1)): 7 | list1[i] = int(list1[i]) 8 | 9 | for i in range(len(list2)): 10 | list2[i] = int(list2[i]) 11 | dict1 = dict(zip(list1, list2)) 12 | 13 | data3 = input("Enter integer elements separated by ,(comma) for keys of dict2: ") 14 | data4 = input("Enter integer elements separated by ,(comma) for values of dict2: ") 15 | list3 = data3.split(",") 16 | list4 = data4.split(",") 17 | for i in range(len(list3)): 18 | list3[i] = int(list3[i]) 19 | 20 | for i in range(len(list4)): 21 | list4[i] = int(list4[i]) 22 | dict2 = dict(zip(list3, list4)) 23 | 24 | dict3 = {} 25 | for i in dict1.keys(): 26 | if i in dict2.keys(): 27 | dict3[i]=dict1[i]+ dict2[i] 28 | else: 29 | dict3[i]=dict1[i] 30 | for i in dict2.keys(): 31 | if i not in dict3.keys(): 32 | dict3[i]=dict2[i] 33 | print(list(sorted(dict3.items()))) 34 | 35 | -------------------------------------------------------------------------------- /L40/5.py: -------------------------------------------------------------------------------- 1 | a=input('seq: ').split(',') 2 | b={} 3 | c=list(set(a.copy())) 4 | for i in c: 5 | temp=a.count(i) 6 | b[int(i)]=temp 7 | print('sorted dictionary:',list(sorted(b.items()))) -------------------------------------------------------------------------------- /L40/6.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | e=dict(zip(a,b)) 4 | c=input('data3: ').split(',') 5 | d=input('data4: ').split(',') 6 | f=dict(zip(c,d)) 7 | key=input('key: ') 8 | if (key in e.keys()) and (key in f.keys()): 9 | print('key present in both dictionaries') 10 | elif key in e.keys(): 11 | print('key present in first dictionary') 12 | elif key in f.keys(): 13 | print('key present in second dictionary') 14 | else: 15 | print('key is not present') -------------------------------------------------------------------------------- /L40/7.py: -------------------------------------------------------------------------------- 1 | a=input('data1: ').split(',') 2 | b=input('data2: ').split(',') 3 | dic1= dict(sorted(zip(a,b))) 4 | dic2=dict(sorted(zip(b,a))) 5 | print('dictionary with key order') 6 | for i,j in dic1.items(): 7 | print(i,j) 8 | print('dictionary with value order') 9 | for i,j in dic2.items(): 10 | print(i,j) 11 | -------------------------------------------------------------------------------- /L40/8.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data1: ').split(','))) 2 | b=list(map(int,input('data2: ').split(','))) 3 | c=list(map(int,input('data3: ').split(','))) 4 | d=list(map(int,input('data4: ').split(','))) 5 | e=dict(zip(a,b)) 6 | f=dict(zip(c,d)) 7 | for i in f.keys(): 8 | if i in e.keys(): 9 | e[i]+=f[i] 10 | else: 11 | e[i]=f[i] 12 | print('concatenation:',list(sorted(e.items()))) -------------------------------------------------------------------------------- /L40/9.py: -------------------------------------------------------------------------------- 1 | a=list(map(int,input('data1: ').split(','))) 2 | b=list(map(int,input('data2: ').split(','))) 3 | c=list(map(int,input('data3: ').split(','))) 4 | d=list(map(int,input('data4: ').split(','))) 5 | e=dict(zip(a,b)) 6 | f=dict(zip(c,d)) 7 | g={} 8 | for i in e.keys(): 9 | if i in f.keys(): 10 | g[i]=e[i]+f[i] 11 | print('common keys:',list(sorted(g.items()))) -------------------------------------------------------------------------------- /L41/1.py: -------------------------------------------------------------------------------- 1 | data1=input("data1: ").split(',') 2 | data2=input("data2: ").split(',') 3 | data3=input("data3: ").split(',') 4 | data4=input("data4: ").split(',') 5 | p=dict(sorted(zip(data1,data2))) 6 | l=dict(sorted(zip(data3,data4))) 7 | # a=list(sorted(zip(data1,data2))) 8 | # b=list(sorted(zip(data3,data4))) 9 | print("sorted dictionary:",list(p.items())) 10 | k=p.copy() 11 | print("copy of sorted dictionary:",list(k.items())) 12 | print("sorted keys of dictionary:",list(k.keys())) 13 | print("sorted values of dictionary:",list(k.values())) 14 | # r=p+l 15 | 16 | p.update(l) 17 | print("sorted dictionary after updation:",list(sorted(p.items()))) -------------------------------------------------------------------------------- /L41/2.py: -------------------------------------------------------------------------------- 1 | dct = {'1':'apple', '2':'orange', '3':'mango', '4':'banana'} 2 | print("dct_keys = dct.keys()") 3 | dct_keys = dct.keys() 4 | print("dct_values = dct.values()") 5 | dct_values = dct.values() 6 | print("dct_keys_list = list(dct_keys)") 7 | dct_keys_list = list(dct_keys) 8 | print("dct_values_list = list(dct_values)") 9 | dct_values_list = list(dct_values) 10 | print("dct_keys_list =", sorted(dct_keys_list)) 11 | print("dct_values_list =", sorted(dct_values_list)) 12 | print("Combining both the keys and values list using zip"); 13 | print("zip(dct_keys_list, dct_values_list)") 14 | zip_result = zip(dct_keys_list, dct_values_list) 15 | print("Creating a list out of the zip result using list function") 16 | zip_result_list = list(zip_result) 17 | print("zip_result_list =", sorted(zip_result_list)) 18 | print("Finally creating the dictionary from the zip result list") 19 | dict2 = dict(zip_result_list) 20 | print("dict2 =", sorted(dict2.items())) -------------------------------------------------------------------------------- /L41/3.py: -------------------------------------------------------------------------------- 1 | a=input("data1: ").split(',') 2 | b=input("data2: ").split(',') 3 | c=dict(sorted(zip(a,b))) 4 | print("elements:",list(c.items())) 5 | print("sorted keys:",list(sorted(c.keys()))) 6 | print("sorted values:",list(sorted(c.values()))) -------------------------------------------------------------------------------- /L42/Basic Set Operations/1.py: -------------------------------------------------------------------------------- 1 | a=input("data1: ").split(',') 2 | b=input("element: ") 3 | c=set(a) 4 | c.add(b) 5 | print("sorted set after adding:",sorted(c)) 6 | l=input("data2: ").split(',') 7 | c.update(l) 8 | print("sorted set after updating:",sorted(c)) -------------------------------------------------------------------------------- /L42/Basic Set Operations/2.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=input("element to discard: ") 3 | if b in a: 4 | a.discard(b) 5 | print("sorted set after discarding:",sorted(list(a))) 6 | k=input("element to remove: ") 7 | a.remove(k) 8 | print("sorted set after removing:",sorted(list(a))) 9 | else: 10 | print("not in set") -------------------------------------------------------------------------------- /L42/Basic Set Operations/3.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | print("sorted set:",sorted(list(a))) 3 | b=input("element: ") 4 | print(f'is {b} in set: {b in a}') 5 | 6 | -------------------------------------------------------------------------------- /L42/Basic Set Operations/4.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | c=set(input("data3: ").split(',')) 4 | print("set1 sorted:",sorted(list(a))) 5 | print("set2 sorted:",sorted(list(b))) 6 | print("set3 sorted:",sorted(list(c))) 7 | l=a.union(b) 8 | print("union of set1, set2:",sorted(list(l))) 9 | print("union of set1, set2, set3:",sorted(list(l.union(c)))) 10 | print("set1 | set2:",sorted(list(a|b))) 11 | print("set1 | set2| set3:",sorted(list(a|b|c))) -------------------------------------------------------------------------------- /L42/Basic Set Operations/5.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | print("set1 sorted:",sorted(list(a))) 4 | print("set2 sorted:",sorted(list(b))) 5 | print("Intersection:",(list(sorted(a.intersection(b))))) 6 | # k=list(a&b) 7 | print("sorted set after (set1 & set2):",list(sorted(a&b))) 8 | # l=list(a&=b) 9 | print("sorted set1 after (set1 &= set2):",list(sorted(a&b))) 10 | 11 | print("sorted set2 after (set1 &= set2):",list(sorted(b))) -------------------------------------------------------------------------------- /L42/Basic Set Operations/6.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | print("set1 sorted:",sorted(list(a))) 4 | print("set2 sorted:",sorted(list(b))) 5 | print("difference using difference():",sorted(list(a.difference(b)))) 6 | li=a.difference(b) 7 | print("difference using difference_update():",sorted(list(li))) 8 | print("difference using (set1 - set2):",sorted(list(a-b))) 9 | k=a-b 10 | print("difference using (set1 -= set2):",sorted(list(k))) 11 | 12 | -------------------------------------------------------------------------------- /L42/Basic Set Operations/7.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | print("symmetric difference:",sorted(list(a.symmetric_difference(b)))) 4 | print("set1 ^ set2:",sorted(list(a.symmetric_difference(b)))) 5 | print("set1 sorted:",sorted(list(a.symmetric_difference(b)))) 6 | print("set2 sorted:",sorted(list(b))) 7 | c=set(input("data3: ").split(',')) 8 | d=set(input("data4: ").split(',')) 9 | print("set3 after (set3 ^= set4):",sorted(list(c.symmetric_difference(d)))) 10 | print("set4 after (set3 ^= set4):",sorted(list(d))) -------------------------------------------------------------------------------- /L42/Introduction to Sets/1.txt: -------------------------------------------------------------------------------- 1 | Members in a set are immutable. -------------------------------------------------------------------------------- /L42/Introduction to Sets/2.txt: -------------------------------------------------------------------------------- 1 | Set does not maintain the order of insertion -------------------------------------------------------------------------------- /L42/Introduction to Sets/3.py: -------------------------------------------------------------------------------- 1 | #Write your code here 2 | a=input("data1: ").split(',') 3 | print("sorted set:",sorted(set(a))) -------------------------------------------------------------------------------- /L43/1.txt: -------------------------------------------------------------------------------- 1 | s1 = {1, 2}s1.add(5)s2 = s1.copy() will result in s1 = {1, 2, 5} and s2 = {1, 2, 5} 2 | 3 | You can have frozen sets as members of a set. -------------------------------------------------------------------------------- /L43/2.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | c=set(input("data3: ").split(',')) 4 | print("set1 sorted:",sorted(list(a))) 5 | print("set2 sorted:",sorted(list(b))) 6 | print("set3 sorted:",sorted(list(c))) 7 | print("is set1 subset of set2?",a.issubset(b)) 8 | print("is set2 subset of set1?",b.issubset(a)) 9 | print("is set1 subset of set3?",a.issubset(c)) 10 | print("is set3 subset of set1?",c.issubset(a)) 11 | print("is set2 subset of set3?",b.issubset(c)) 12 | print("is set3 subset of set2?",c.issubset(b)) -------------------------------------------------------------------------------- /L43/3.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | c=set(input("data3: ").split(',')) 4 | print("set1 sorted:",sorted(list(a))) 5 | print("set2 sorted:",sorted(list(b))) 6 | print("set3 sorted:",sorted(list(c))) 7 | print("is set1, set2 disjoint?",a.isdisjoint(b)) 8 | print("is set1, set3 disjoint?",a.isdisjoint(c)) 9 | print("is set2, set3 disjoint?",b.isdisjoint(c)) 10 | # print 11 | # print -------------------------------------------------------------------------------- /L43/4.py: -------------------------------------------------------------------------------- 1 | a=set(input("data1: ").split(',')) 2 | b=set(input("data2: ").split(',')) 3 | c=set(input("data3: ").split(',')) 4 | print("engineers:",sorted(list(a))) 5 | print("programmers:",sorted(list(b))) 6 | print("managers:",sorted(list(c))) 7 | print("employees:",sorted(list(a.union(b,c)))) 8 | emp=set(list(a)+list(b)+list(c)) 9 | e=input("element into engineers: ") 10 | a=list(a) 11 | a.append(e) 12 | a=set(a) 13 | print("engineers:",(sorted(list(a)))) 14 | print("employees.issuperset of engineers:",emp.issuperset(a)) 15 | print("let us update employees from engineers") 16 | emp.add(e) 17 | print("employees.issuperset of engineers:",emp.issuperset(b)) 18 | el=input("element to remove from engineers, programmers, managers, employees: ") 19 | a.discard(el) 20 | print("engineers:",sorted(list(a))) 21 | b.discard(el) 22 | print("programmers:",sorted(list(b))) 23 | c.discard(el) 24 | print("managers:",sorted(list(c))) 25 | emp.discard(el) 26 | print("employees:",sorted(list(emp))) 27 | -------------------------------------------------------------------------------- /L44/1.py: -------------------------------------------------------------------------------- 1 | str1=input("str: ") 2 | p=[i for i in str1] 3 | print(p) 4 | -------------------------------------------------------------------------------- /L44/2.py: -------------------------------------------------------------------------------- 1 | a=[i for i in range(0,50) if i%2==0 and i%3==0 ] 2 | print(a) -------------------------------------------------------------------------------- /L44/3.py: -------------------------------------------------------------------------------- 1 | matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]] 2 | print("matrix:") 3 | print(matrix) 4 | # write your code here 5 | # print("transposition using nested while:") 6 | # res= 7 | print("transposition using nested while:") 8 | rez=[[matrix[j][i] for j in range(len(matrix))] for i in range(len(matrix[0]))] 9 | print(rez) 10 | print("transposition using nested for:") 11 | print(rez) 12 | print("transposition single list comprehension:") 13 | print(rez) 14 | print('transposition double list comprehension:') 15 | print(rez) -------------------------------------------------------------------------------- /L44/4.py: -------------------------------------------------------------------------------- 1 | print("contents:",[int(x) for x in input('data: ').split()]) -------------------------------------------------------------------------------- /L45/1.py: -------------------------------------------------------------------------------- 1 | n=int(input("n1: ")) 2 | n2=int(input("n2: ")) 3 | my_set = {i**2 if i % 2 == 0 else i**3 for i in range(n,n2)} 4 | 5 | print(sorted(list(my_set))) -------------------------------------------------------------------------------- /L45/2.py: -------------------------------------------------------------------------------- 1 | my_set = {(u,t,s) for s in range(1,30) for t in range(s,30+1) for u in range(1,30+1) if s**2+t**2==u**2 } 2 | print(sorted((my_set))) -------------------------------------------------------------------------------- /L46/1.py: -------------------------------------------------------------------------------- 1 | from string import ascii_uppercase 2 | from collections import OrderedDict 3 | a={(i,chr(i)) for i in range(65,91)} 4 | b={(chr(i),i) for i in range(65,91)} 5 | print(sorted(a)) 6 | print(sorted(b)) -------------------------------------------------------------------------------- /L47/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L47/1.jpg -------------------------------------------------------------------------------- /L47/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L47/2.jpg -------------------------------------------------------------------------------- /L47/3.py: -------------------------------------------------------------------------------- 1 | def helloworld(): 2 | print('Hello World') 3 | print('Good morning') 4 | print('Have a nice day') 5 | print('The function ends') 6 | 7 | 8 | helloworld() -------------------------------------------------------------------------------- /L47/4.py: -------------------------------------------------------------------------------- 1 | def add(x, y): 2 | # add x, y and print the result 3 | print(x+y) 4 | def sub(x, y): 5 | # subtract x, y and print the result 6 | print(x-y) 7 | def mul(x, y): 8 | # multiply x, y and print the result 9 | print(x*y) 10 | 11 | # take inputs x and y from the user 12 | # call the functions add,sub, mul 13 | a=int(input('x: ')) 14 | b=int(input('y: ')) 15 | add(a,b) 16 | sub(a,b) 17 | mul(a,b) -------------------------------------------------------------------------------- /L47/5.py: -------------------------------------------------------------------------------- 1 | a=int(input('a: ')) 2 | b=int(input('b: ')) 3 | def add(a,b): 4 | print(a+b) 5 | def sub(a,b): 6 | print(a-b) 7 | def mul(a,b): 8 | print(a*b) 9 | add(a,b) 10 | sub(a,b) 11 | mul(a,b) -------------------------------------------------------------------------------- /L47/6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L47/6.jpg -------------------------------------------------------------------------------- /L47/7.py: -------------------------------------------------------------------------------- 1 | a=int(input('a: ')) 2 | b=int(input('b: ')) 3 | def add(a,b): 4 | return a+b 5 | def sub(a,b): 6 | return a-b 7 | def ave(a,b): 8 | return (a+b)/2 9 | def mul(a,b): 10 | return a*b 11 | 12 | print(f"sum, average: ({add(a,b)}, {ave(a,b)})") 13 | print('subtraction:',sub(a,b)) 14 | print('multiplication:',mul(a,b)) 15 | -------------------------------------------------------------------------------- /L47/8.py: -------------------------------------------------------------------------------- 1 | def add(a,b): 2 | return a+b 3 | def sub(a,b): 4 | return a-b 5 | a=int(input('a: ')) 6 | b=int(input('b: ')) 7 | print('addition:',add(a,b)) 8 | print('subtraction:',sub(a,b)) -------------------------------------------------------------------------------- /L48/Keyword Arguments/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L48/Keyword Arguments/1.jpg -------------------------------------------------------------------------------- /L48/Keyword Arguments/2.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate keyword parameters 2 | def simplecalc(a=3,b=4): 3 | print('addition:',a+b) 4 | print('subtraction:',a-b) 5 | print('multiplication:',a*b) 6 | 7 | #define your function here and perform arithmetic operations addition, subtraction, multiplicateion and print the result. 8 | 9 | simplecalc(a = 3, b = 5) 10 | simplecalc(b = 4, a = 5) 11 | #This function can also be called with positional arguments 12 | simplecalc(8, 4) -------------------------------------------------------------------------------- /L48/Keyword Arguments/3.py: -------------------------------------------------------------------------------- 1 | def say(name,tym): 2 | print(f'Good {tym} {name}') 3 | print(f'Good {tym} {name}') 4 | name=input('name: ') 5 | tym=input('morning/night: ') 6 | say(name,tym) -------------------------------------------------------------------------------- /L48/Keyword Arguments/4.py: -------------------------------------------------------------------------------- 1 | def nameage(name,age): 2 | print(name,age) 3 | name=input('name: ') 4 | age=input('age: ') 5 | nameage(name,age) 6 | nameage(name,age) -------------------------------------------------------------------------------- /L48/Parameters and Arguments/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L48/Parameters and Arguments/1.jpg -------------------------------------------------------------------------------- /L48/Parameters and Arguments/2.py: -------------------------------------------------------------------------------- 1 | 2 | a=int(input('a: ')) 3 | b=int(input('b: ')) 4 | def add(a,b): 5 | val=a+b 6 | return val 7 | print(add(a,b)) -------------------------------------------------------------------------------- /L48/Parameters and Arguments/3.py: -------------------------------------------------------------------------------- 1 | def sayhello(username): 2 | return 'Hello '+username 3 | 4 | users = ['Ram', 'Mahesh', 'Vasudha', 'Uma', 'Sekhar', 'John'] 5 | 6 | for i in users: 7 | print(sayhello(i)) -------------------------------------------------------------------------------- /L48/Parameters and Arguments/4.py: -------------------------------------------------------------------------------- 1 | n=int(input('num: ')) 2 | list=[1] 3 | for i in range(1,n+1): 4 | print(list) 5 | newlist=[] 6 | newlist.append(list[0]) 7 | for i in range(len(list)-1): 8 | newlist.append(list[i]+list[i+1]) 9 | newlist.append(list[-1]) 10 | list=newlist -------------------------------------------------------------------------------- /L49/Default Arguments/1.py: -------------------------------------------------------------------------------- 1 | def simplecalc(a, b = 100): 2 | print('addition:',a+b) 3 | print('subtraction:',a-b) 4 | print('multiplication:',a*b) 5 | 6 | num1=int(input('num1: ')) 7 | num2=int(input('num2: ')) 8 | simplecalc(a = num1) 9 | simplecalc(b = num2, a = num1) -------------------------------------------------------------------------------- /L49/Default Arguments/2.py: -------------------------------------------------------------------------------- 1 | def cal(salary,percent=20): 2 | tax=salary*percent/100 3 | print(tax) 4 | # print(tax) 5 | salary=float(input('salary: ')) 6 | per=float(input('tax percentage: ')) 7 | cal(salary) 8 | cal(salary,per) -------------------------------------------------------------------------------- /L49/Default Arguments/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L49/Default Arguments/3.jpg -------------------------------------------------------------------------------- /L49/Default Arguments/4.py: -------------------------------------------------------------------------------- 1 | def fun1(name='Padma',age=12): 2 | '''Body of the function''' 3 | print(name,"is",age,'years old.') 4 | fun1('Aruna',16) 5 | fun1('Karuna',16) 6 | fun1('Padma',16) 7 | fun1('Karuna',12) 8 | fun1('Padma',12) -------------------------------------------------------------------------------- /L49/Variable-length Arguments/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L49/Variable-length Arguments/1.jpg -------------------------------------------------------------------------------- /L49/Variable-length Arguments/2.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate variable number of arguments 2 | def mySum(*args): 3 | sum=0 4 | for i in args: 5 | sum+=i 6 | return sum 7 | 8 | #Write your code here 9 | 10 | print(mySum(1, 2, 3, 4, 5, 6, 7)) #7 arguments 11 | print(mySum(1, 2)) #2 arguments 12 | print(mySum(1, 2, 3)) #3 arguments -------------------------------------------------------------------------------- /L49/Variable-length Arguments/3.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate Variable number of arguments 2 | def largestNumber( * numbers): 3 | print("largest: "+str(max(numbers))) 4 | # return a 5 | 6 | # write your code here 7 | 8 | 9 | 10 | largestNumber(1, 2, 3, 4) #4 arguments 11 | largestNumber(8, 9, 3, 4, 2, 5) #6 arguments -------------------------------------------------------------------------------- /L5/2.py: -------------------------------------------------------------------------------- 1 | a = 365 2 | #Print type of a 3 | print(type(a)) 4 | 5 | a = 345.65 6 | #Print type of a 7 | print(type(a)) 8 | 9 | 10 | a = 45 + 5j 11 | #Print type of a 12 | print(type(a)) -------------------------------------------------------------------------------- /L5/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L5/3.jpg -------------------------------------------------------------------------------- /L5/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L5/5.jpg -------------------------------------------------------------------------------- /L50/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/warriorwizard/CodeTantra-python-placement/a498bc6f750d0a4455b84b3fd01892219f37b9be/L50/1.jpg -------------------------------------------------------------------------------- /L50/2.py: -------------------------------------------------------------------------------- 1 | tax = lambda salary: salary *20 /100 # write the expression here 2 | 3 | salary = int(input("Please enter your salary: ")) 4 | print("Tax to be paid is", tax(salary)) -------------------------------------------------------------------------------- /L50/3.py: -------------------------------------------------------------------------------- 1 | cal=lambda x: x*2 2 | a=int(input('a: ')) 3 | print(cal(a)) -------------------------------------------------------------------------------- /L50/4.py: -------------------------------------------------------------------------------- 1 | def squares(x): 2 | return x ** 2 3 | list1 = [1, 2, 3, 4, 5] 4 | #use the squares func inside map function print the result 5 | print(list(map(squares,list1))) 6 | 7 | #use the lambda func inside map function print the result 8 | print(list(map(lambda x: x**2,list1))) 9 | #use list comprehension to get equivalent behaviour as map and print the result 10 | print([x**2 for x in list1]) -------------------------------------------------------------------------------- /L50/5.py: -------------------------------------------------------------------------------- 1 | a = [1, 2, 3, 5, 7, 9] 2 | b = [2, 3, 6, 7, 9, 8] 3 | # apply lambda function to the filter function and print the result 4 | print(list(filter(lambda x: x in a,b))) 5 | # print the result using list comprehension 6 | print([x for x in a if x in b]) 7 | # follow the example given in description -------------------------------------------------------------------------------- /L51/1.txt: -------------------------------------------------------------------------------- 1 | A fruitful function is a function, it returns a value when it is called. 2 | 3 | A return statement consists of the return keyword followed by an expression. 4 | 5 | Python returns immediately when it reaches a return statement . -------------------------------------------------------------------------------- /L51/2.py: -------------------------------------------------------------------------------- 1 | def largestinthree(a, b, c): 2 | if a>b and a>c: 3 | return a 4 | elif b>a and b>c: 5 | return b 6 | else: 7 | return c 8 | # write your code here to find the largest number in a, b and c 9 | 10 | num1 = int(input("Please enter a value for num1: ")) 11 | num2 = int(input("Please enter a value for num2: ")) 12 | num3 = int(input("Please enter a value for num3: ")) 13 | 14 | result = largestinthree(num1, num2, num3) 15 | 16 | print("Largest of the values entered is", result) -------------------------------------------------------------------------------- /L51/3.py: -------------------------------------------------------------------------------- 1 | def largestintwo(num1,num2): 2 | if num1>num2: 3 | return num1 4 | else: 5 | return num2 6 | 7 | 8 | # write your code here 9 | 10 | num1=int(input("num1: ")) 11 | num2=int(input("num2: ")) 12 | 13 | result = largestintwo(num1, num2) 14 | print("largest:", result) -------------------------------------------------------------------------------- /L51/4.py: -------------------------------------------------------------------------------- 1 | def computeGCD(x, y): 2 | 3 | 4 | # write your code here 5 | while(y): 6 | x,y=y,x%y 7 | return x 8 | x=int(input("x: ")) 9 | y=int(input("y: ")) 10 | print(computeGCD(x,y)) 11 | -------------------------------------------------------------------------------- /L52/Function Composition/1.py: -------------------------------------------------------------------------------- 1 | def square(x): 2 | # find square of a given number and return the result 3 | a=(x**2) 4 | 5 | return a 6 | 7 | def double(x): 8 | 9 | # double the given number and return the result 10 | a=2*x 11 | return a 12 | # take the user input 13 | x=int(input("num: ")) 14 | 15 | print("double, squaring the value:",square(double(x)) ) -------------------------------------------------------------------------------- /L52/Function Composition/2.py: -------------------------------------------------------------------------------- 1 | def compose(*functions): 2 | def inner(arg): 3 | for f in reversed(functions): 4 | arg =f(arg) 5 | return arg 6 | return inner 7 | def square(x): 8 | return x**2 9 | def increment(x): 10 | return x+1 11 | def half(x): 12 | return x/2 13 | composed = compose(square, increment, half) 14 | print(composed(5)) 15 | # square(increment(half(x))) 16 | composed=compose(square, increment) 17 | print(composed(5)) 18 | 19 | -------------------------------------------------------------------------------- /L52/Global and Local Variables/1.py: -------------------------------------------------------------------------------- 1 | # write your code here 2 | def test1(): 3 | a=50 4 | b=80 5 | print(a,b) 6 | def test2(): 7 | a=22 8 | b=44 9 | print(a,b) 10 | test1() 11 | test2() -------------------------------------------------------------------------------- /L52/Global and Local Variables/2.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate Global variable access 2 | globvar = "Hello" 3 | def test1(): 4 | global globvar 5 | globvar = "Good Morning" 6 | def test2(): 7 | # Here this is a local variable 8 | globvar = "Night Night" 9 | print(globvar) # The first value "Hello" is printed 10 | # call the function test1 11 | test1() 12 | test2() 13 | # call the function test2 14 | print(globvar) # The updated value of test1 is printed -------------------------------------------------------------------------------- /L52/Global and Local Variables/3.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate Global and Local Variables 2 | 3 | # take input a from the user 4 | a=int(input("a: ")) 5 | def changeglobal(): 6 | global a 7 | a = 200 8 | def changelocal(): 9 | a = 500 10 | print("local a value:", a) 11 | print("global a before function call:", a) 12 | # call the function changeglobal 13 | changeglobal() 14 | changelocal() 15 | # call the function changelocal 16 | print("global a after function call:", a) # print value of a here -------------------------------------------------------------------------------- /L53/1.txt: -------------------------------------------------------------------------------- 1 | A function call when made within the definition of the same function is known as a recursion function. 2 | 3 | Every time a recursive call is made, the arguments passed to the function should be closer to the base criteria. -------------------------------------------------------------------------------- /L53/2.txt: -------------------------------------------------------------------------------- 1 | In circular recursion more than one function is involved. -------------------------------------------------------------------------------- /L53/3.py: -------------------------------------------------------------------------------- 1 | #Program to illustrate recursion 2 | def recurfact(n): 3 | if n==1: 4 | return n 5 | else: 6 | return n*recurfact(n-1) 7 | num=int(input("num: ")) 8 | if num<0: 9 | print("factorial not exist for negative number") 10 | elif num==0: 11 | print("factorial: 1") 12 | else: 13 | print("factorial:",recurfact(num)) 14 | -------------------------------------------------------------------------------- /L53/4.py: -------------------------------------------------------------------------------- 1 | def r_sum(nested_num_list): 2 | total=0 3 | for j in range(len(nested_num_list)): 4 | if type(nested_num_list[j])==list: 5 | total +=r_sum(nested_num_list[j]) 6 | 7 | else: 8 | total+=nested_num_list[j] 9 | return total 10 | 11 | # write your code here 12 | 13 | 14 | 15 | L1 = [1, 10, 9, [3, 5, 7], [5, [6, 7], 97]] 16 | print(r_sum(L1)) -------------------------------------------------------------------------------- /L53/5.py: -------------------------------------------------------------------------------- 1 | #Program to add two numbers using recursion 2 | def add(x, y): 3 | if y==0: 4 | return x 5 | a=add(x,y-1)+1 6 | return a 7 | a=int(input("a: ")) 8 | b=int(input("b: ")) 9 | 10 | 11 | 12 | 13 | # write your code here 14 | 15 | 16 | 17 | 18 | 19 | print(add(a, b)) -------------------------------------------------------------------------------- /L54/1.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | dob=(input("dob in ddmmyyyy format: ")) 3 | tod=(input("today's date in ddmmyyyy format: ")) 4 | a=datetime.strptime(dob,'%d%m%Y') 5 | b=datetime.strptime(tod, '%d%m%Y') 6 | k=b-a 7 | print("days since birthday:",k.days) -------------------------------------------------------------------------------- /L54/2.py: -------------------------------------------------------------------------------- 1 | def valley(l): 2 | bol=0 3 | count=0 4 | for i in range(0,len(l)-1): 5 | if l[i+1]==l[i]: 6 | return False 7 | elif l[i+1]l[i] and bol==0: 10 | bol=1 11 | elif l[i+1]< l[i] and bol==1: 12 | return False 13 | if bol== 0 and count==0: 14 | return False 15 | else: 16 | return True 17 | 18 | l=list(input("integers space separated: ").split()) 19 | print(valley(l)) 20 | 21 | 22 | -------------------------------------------------------------------------------- /L54/3.py: -------------------------------------------------------------------------------- 1 | from collections import Counter 2 | 3 | def frequency (seq): 4 | b=seq.copy() 5 | a=Counter(b) 6 | mini=9999 7 | maxi=-9999 8 | for i in set(b): 9 | if a[i]maxi: 12 | maxi=a[i] 13 | min_lis=[] 14 | max_lis=[] 15 | for i in set(b): 16 | if a[i]==mini: 17 | min_lis.append(i) 18 | if a[i]==maxi: 19 | max_lis.append(i) 20 | return (sorted(min_lis),sorted(max_lis),mini,maxi) 21 | 22 | 23 | 24 | 25 | # write your code here 26 | 27 | 28 | 29 | 30 | 31 | 32 | l1 = [int(x) for x in input("Please enter integers separated by spaces: ").split()] 33 | print (frequency(l1)) -------------------------------------------------------------------------------- /L55/1.txt: -------------------------------------------------------------------------------- 1 | In early times, all the programming languages had huge lines of code that increased in leaps and bounds. 2 | 3 | A module contains a set of classes, functions, variables hat got together to get a specific set of tasks done. 4 | 5 | In Python, a module is a python file (.py). -------------------------------------------------------------------------------- /L55/2.py: -------------------------------------------------------------------------------- 1 | courses = ['Java','Python','C','C plus'] 2 | 3 | def arithoperations(num1,num2): 4 | print("addition:",num1+num2) 5 | print("subtraction:",num1-num2) 6 | print("multiplication:",num1*num2) 7 | print("division:",num1/num2) 8 | # Compute addition of two argument 9 | 10 | # Compute substraction of two arguments 11 | #Compute multiplication 12 | #Compute division 13 | 14 | def compoperations(num1,num2): 15 | print("is greater than:",num1>num2) 16 | print("is less than:",num1int(year): 9 | print(year1-int(year),'years after the current year') 10 | else: 11 | print(int(year)-year1,'years before the current year') 12 | # print("year before/after the current year:") 13 | # print(f' years before the current year') 14 | -------------------------------------------------------------------------------- /L74/Dates and Times/4.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from datetime import date 3 | from datetime import timedelta 4 | 5 | # take the date input from the user 6 | d=input('date in yyyy-mm-dd format: ') 7 | year, month, day = d.split('-') 8 | d = datetime.date(int(year), int(month), int(day)) 9 | print('adding 3 days:',d+timedelta(days=3)) 10 | # add 3 days to the given date using timedelta function 11 | 12 | # print the new date -------------------------------------------------------------------------------- /L74/Dates and Times/5.py: -------------------------------------------------------------------------------- 1 | from datetime import timedelta,date,datetime 2 | #define two years del1 and del2 specifying the number of days in the year. 3 | #Let us do some operations 4 | del1=timedelta(int(input("days in 1st year: "))) 5 | del2=timedelta(int(input("days in 2nd year: "))) 6 | # print(del1) 7 | 8 | # find del1 - del2 and print the result 9 | print("d3 = d1 - d2:",(del1-del2)) 10 | print("d3 = d1 + d2:",del1+del2) 11 | print("d3 = d1 / d2:",del1/del2) 12 | print("d3 = d1 % d2:",del1%del2) 13 | print("d3 = d1 * 2:",del1*2) 14 | # print("d3 = d1-d2:",del1+del2,"days") 15 | 16 | # find del1 + del2 and print the result 17 | 18 | # find del1 / del2 and print the result 19 | 20 | # find del1 % del2 and print the result 21 | 22 | # find del1 * 2 and print the result -------------------------------------------------------------------------------- /L74/Dates and Times/6.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from datetime import date,timedelta 3 | a=((input("date in yyyy-mm-dd format: "))) 4 | year, month, day=a.split('-') 5 | a=datetime.date(int(year), int(month), int(day)) 6 | week=int(input("weeks: ")) 7 | print("date after",week,"weeks:",a+timedelta(days=7*week)) 8 | 9 | -------------------------------------------------------------------------------- /L74/Dates and Times/7.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | # from datetime import time,datetime 3 | # earliest=6,30,56 4 | # earliest=datetime.combine(earliest, t) 5 | # value = datetime.strptime(value, format) 6 | 7 | # create a time object with hour = 6, minute = 30, second = 56, microsecond = 30 8 | time1=datetime.time(6, 30, 56,30) 9 | print("Time object created t1:",time1) 10 | # print the created time object t1 -------------------------------------------------------------------------------- /L74/Dates and Times/8.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | from datetime import date 3 | d=input("date in yyyy-mm-dd format: ") 4 | year, month, day=d.split('-') 5 | d=datetime.date(int(year), int(month), int(day)) 6 | print("date, time object:",d) 7 | print(d.isoweekday(),"day of week") -------------------------------------------------------------------------------- /L74/Dates and Times/9.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | import time 3 | 4 | import datetime 5 | 6 | from datetime import date 7 | 8 | import locale 9 | 10 | #Taking input date from the user and convert into int formate using datetime object 11 | year,month,day=input("date in yyyy-mm-dd format: ").split('-') 12 | x=date(int(year),int(month),int(day)) 13 | print('date, time in locale format:',x.strftime("%c")) 14 | print("weekday in locale format:",x.strftime("%a")) 15 | print('date in locale format:',x.strftime('%x')) 16 | # print Date and Time in locale formate 17 | # d=time.strftime("%c") 18 | # print("date, time in locale format:",d) 19 | 20 | 21 | 22 | # print the Weekday in locale formate 23 | 24 | # print Date in locale formate 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /L74/Math/1.txt: -------------------------------------------------------------------------------- 1 | The math module provides access to the mathematical functions defined by C. 2 | 3 | Most of the functions of math module return float values. 4 | 5 | 6 | The cmath module has functions of the same name as math module, but they work on complex numbers. -------------------------------------------------------------------------------- /L74/Math/2.py: -------------------------------------------------------------------------------- 1 | import math 2 | x = 10 3 | 4 | # find factorial of x and print the result 5 | print("Factorial of 10",math.factorial(x)) 6 | 7 | # find math.floor and print the result 8 | print("Floor of 10",math.floor(x)) 9 | 10 | # add x three times and print the result 11 | k=math.floor(x) 12 | # print(k) 13 | print("Sum of 10 three times",3.0*k) 14 | 15 | 16 | a = 5 17 | b = 6 18 | 19 | # find GCD of a and b and print the result 20 | print(f'GCD of {a} and {b} {math.gcd(a,b)}') 21 | 22 | # find math.isfinite and print the result 23 | print(f'Is {x} a finite number: {math.isfinite(x)}') 24 | 25 | # find math.isinf and print the result 26 | print(f'Is {x} a infinite number: {math.isinf(x)}') -------------------------------------------------------------------------------- /L74/Math/3.py: -------------------------------------------------------------------------------- 1 | import math 2 | x=int(input("x: ")) 3 | print("factorial:",math.factorial(x)) 4 | print("floor:",math.floor(x)) 5 | print("sum three times",3.0*x) 6 | a=int(input("a: ")) 7 | b=int(input("b: ")) 8 | print("gcd:",math.gcd(a,b)) -------------------------------------------------------------------------------- /L74/Math/4.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | # write your code here 4 | x=int(input("x: ")) 5 | print("exponent:",math.exp(x)) 6 | print("math.log1p:",math.log1p(x)) 7 | print("math.log2:",math.log2(x)) 8 | print("math.log10:",math.log10(x)) 9 | print("square root:",math.sqrt(x)) 10 | a=int(input("a: ")) 11 | b=int(input("b: ")) 12 | print("power:",math.pow(a,b)) 13 | -------------------------------------------------------------------------------- /L74/Math/5.py: -------------------------------------------------------------------------------- 1 | import math 2 | x=int(input("x: ")) 3 | print("exponent:",math.exp(x)) 4 | print("math.log2:",math.log2(x)) 5 | print("math.log10:",math.log10(x)) 6 | print("square root:",math.sqrt(x)) 7 | a=int(input("a: ")) 8 | b=int(input("b: ")) 9 | print("power:",math.pow(a,b)) -------------------------------------------------------------------------------- /L74/Math/6.py: -------------------------------------------------------------------------------- 1 | import math 2 | xinrad = int(input("num: ")) 3 | x = math.pi / xinrad 4 | print("arc cosine:",math.acos(x)) 5 | # print the arc sine value 6 | print("arc sine:",math.asin(x)) 7 | # print the arc tan value 8 | 9 | print("arc tangent:", math.atan(x)) 10 | print("cosine:",math.cos(x)) 11 | print("sine:",math.sin(x)) 12 | print("tangent:",math.tan(x)) 13 | 14 | # Retrun the sine of x 15 | # Retrun the tan of x 16 | a = int(input("a: ")) 17 | b = int(input("b: ")) 18 | 19 | # Return the value of atan(y / x), in radians. 20 | print(f'value of atan2({b}, {a}): {math.atan2(b,a)}') 21 | print(f'value of hypot({a}, {b}): {math.hypot(a,b)}') 22 | # Returns the Euclidean norm of given two numbers -------------------------------------------------------------------------------- /L74/Math/7.py: -------------------------------------------------------------------------------- 1 | import math 2 | 3 | # take the integer input from the user 4 | x=int(input("x: ")) 5 | 6 | print("inverse hyperbolic cosine:",math.acosh(x)) 7 | print("inverse hyperbolic sine:",math.asinh(x)) 8 | print("hyperbolic cosine:",math.cosh(x)) 9 | print("hyperbolic sine:",math.sinh(x)) 10 | print("hyperbolic tangent:",math.tanh(x)) 11 | 12 | # follow the above print statement while writing 13 | 14 | # find inverse hyperbolic of sine of and print the result 15 | 16 | # find hyperbolic of cosine of and print the result 17 | 18 | # find hyperbolic of sine of and print the result 19 | 20 | # find hyperbolic of tan of and print the result -------------------------------------------------------------------------------- /L74/Math/8.py: -------------------------------------------------------------------------------- 1 | import math 2 | x=int(input("x: ")) 3 | print("angle to degrees:",math.degrees(x)) 4 | print('angle to radians:',math.radians(x)) 5 | -------------------------------------------------------------------------------- /L74/Operating System Interface/1.txt: -------------------------------------------------------------------------------- 1 | Operating System module is one of the modules that is mostly used in Python. 2 | 3 | 4 | We use the OS module to talk to the underlying operating system. 5 | 6 | 7 | All functions in the OS module raise an OSError in case of an exception. -------------------------------------------------------------------------------- /L74/Operating System Interface/2.py: -------------------------------------------------------------------------------- 1 | import os 2 | try: 3 | print("file name:", os.ctermid()) 4 | 5 | print("groups list:", os.getgroups() )# print the user group details using os.getgroups 6 | except TypeError: 7 | print("exception on getting one of the details") -------------------------------------------------------------------------------- /L74/Operating System Interface/3.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # print the current working directory 4 | print(os.getcwd()) 5 | 6 | # lists all the files in the current directory 7 | print(os.listdir()) 8 | 9 | os.makedirs('dir1/sub-dir1') 10 | 11 | # lists all the files in the current directory 12 | print(os.listdir()) 13 | 14 | 15 | # deletes created directory and the required sub directory 16 | print(os.removedirs('dir1/sub-dir1')) 17 | print(os.listdir()) -------------------------------------------------------------------------------- /L74/Operating System Interface/4.py: -------------------------------------------------------------------------------- 1 | import os 2 | print('statistics:',os.stat('Some_File.txt')) 3 | tup=os.walk(os.getcwd()) 4 | for dirpath, dirname, filename in tup: 5 | print("path:",dirpath) 6 | print("dir name:", dirname) 7 | print("file name:", filename) -------------------------------------------------------------------------------- /L74/Operating System Interface/5.py: -------------------------------------------------------------------------------- 1 | import os 2 | print(os.getcwd()) 3 | os.makedir('new_dir/new_sub_dir') 4 | print(os.listdir()) 5 | os.rmdir('new_dir/new_sub_dir') 6 | -------------------------------------------------------------------------------- /L74/String Pattern Matching/1.txt: -------------------------------------------------------------------------------- 1 | A regular expression, regex or regexp is a sequence of characters that define a search pattern. 2 | 3 | Each character in a regular expression is a meta character, having a special meaning, or a regular character that has a actual meaning. 4 | 5 | 6 | Regular expressions were popular from 1968 for pattern matching in a text editor and lexical analysis in a compiler. -------------------------------------------------------------------------------- /L74/String Pattern Matching/10.py: -------------------------------------------------------------------------------- 1 | # write your code here 2 | import re 3 | mystring=input("data: ") 4 | val=mystring.split(',') 5 | match=re.search('(\w+),(\w+),(\w+),(\w+)',mystring) 6 | 7 | # print(data) 8 | if match and len(val)==4: 9 | print("full:",match.group()) 10 | print("group 1:",match.group(1)) 11 | print("group 2:",match.group(2)) 12 | print("group 3:",match.group(3)) 13 | print("group 4:",match.group(4)) 14 | else: 15 | print("you have not entered 4 words") -------------------------------------------------------------------------------- /L74/String Pattern Matching/2.txt: -------------------------------------------------------------------------------- 1 | A regular expression, is called a pattern. 2 | 3 | An atom is a single point within the regex pattern which it tries to match to the target string. 4 | 5 | The simplest atom is a literal. -------------------------------------------------------------------------------- /L74/String Pattern Matching/3.txt: -------------------------------------------------------------------------------- 1 | [ ] These are used for specifying a character class. 2 | 3 | * is used as a repeated qualifier for 0 or more times. -------------------------------------------------------------------------------- /L74/String Pattern Matching/4.txt: -------------------------------------------------------------------------------- 1 | Pattern objects have several methods and attributes like match(), search() etc. 2 | 3 | 4 | The match() and search() return a None if no match is found. 5 | 6 | 7 | 8 | start() method on match object returns the starting position of the match. -------------------------------------------------------------------------------- /L74/String Pattern Matching/5.py: -------------------------------------------------------------------------------- 1 | import re 2 | mystring = "Hello!! Good Morning, Welcome to python tutorial class 24.For any queries please email to contactus@codetantra.com" 3 | 4 | # write your code here 5 | print(re.findall('^Hello',mystring)) 6 | print(re.findall(r'\d+',mystring)) 7 | p=re.compile('ac*|c') 8 | print(p.findall(mystring)) 9 | -------------------------------------------------------------------------------- /L74/String Pattern Matching/6.py: -------------------------------------------------------------------------------- 1 | import re 2 | mystring = "Hello!! Good Morning, Welcome to python tutorial class 24." 3 | matches = re.findall(r'eo*|oo*|o',mystring)# find all occcurences of e and o 4 | 5 | for m in matches: 6 | print(m) 7 | 8 | # print m 9 | -------------------------------------------------------------------------------- /L74/String Pattern Matching/7.py: -------------------------------------------------------------------------------- 1 | import re 2 | string=input("string with email address: ") 3 | val=re.findall(r'([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)',string) 4 | if len(val)>0: 5 | print('email address:',val) 6 | else: 7 | print('No email address found') -------------------------------------------------------------------------------- /L74/String Pattern Matching/8.txt: -------------------------------------------------------------------------------- 1 | Compilation flags lets a user modify a few parts of regular expressions. 2 | 3 | 4 | IGNORECASE, I is used for case-insensitive matches. -------------------------------------------------------------------------------- /L74/String Pattern Matching/9.py: -------------------------------------------------------------------------------- 1 | # impirt re 2 | import re 3 | 4 | mystring = "The alternate email address is victory@ct.com" 5 | match = re.search('(\w+)@(\w+).(\w+)', mystring) 6 | if match: 7 | # find full match text and print the result 8 | print("Full match:",match.group()) 9 | 10 | # find the match text corresponding to the 1st left parenthesis and print 11 | print("Group 1:",match.group(1)) 12 | 13 | # find the match text corresponding to the 2nd left parenthesis and print 14 | print("Group 2:",match.group(2)) 15 | 16 | # find the match text corresponding to the 3rd left parenthesis and print 17 | print("Group 3:",match.group(3)) -------------------------------------------------------------------------------- /L74/Turtle Graphics/1.txt: -------------------------------------------------------------------------------- 1 | Turtle module is a part of standard library. -------------------------------------------------------------------------------- /L74/Turtle Graphics/2.txt: -------------------------------------------------------------------------------- 1 | turtle.setx(x) Sets the Turtle to x coordinate. -------------------------------------------------------------------------------- /L74/Turtle Graphics/3.txt: -------------------------------------------------------------------------------- 1 | tilt() Returns the tilt angle -------------------------------------------------------------------------------- /L74/Turtle Graphics/6.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | screen = turtle.Screen() 3 | turtle.penup() 4 | turtle.write("Press the Up/Down or a to change background color ", font = ('Arial', 10, 'bold')) 5 | def up(): 6 | screen.bgcolor('blue') 7 | def down(): 8 | screen.bgcolor('green') 9 | screen.onkey(up, "Up") 10 | screen.onkeypress(down, "Down") 11 | screen.listen() 12 | turtle.done() -------------------------------------------------------------------------------- /L75/Basic concepts of testing/1.txt: -------------------------------------------------------------------------------- 1 | Functional Testing is a test that tests the if the application meets the business requirements. 2 | 3 | 4 | Functional Testing tests if the complete application meets the end users requirement. 5 | 6 | The non functional requirements are used to test the quality of the application, the performance of the application etc. -------------------------------------------------------------------------------- /L75/Basic concepts of testing/2.txt: -------------------------------------------------------------------------------- 1 | Unit Testing is a micro level testing of individual units of code, to make sure that every unit is working in the intended way it should. 2 | 3 | 4 | A unit is a piece of code that meets a specific functionality, it is generally a program within the application. 5 | 6 | Unit test is a library in Python that can be used to write unit tests. -------------------------------------------------------------------------------- /L75/Basic concepts of testing/3.txt: -------------------------------------------------------------------------------- 1 | Integration testing tests how the units integrate and work together. 2 | 3 | Big Bang Testing is not very efficient way of integration testing. 4 | 5 | Top Down Approach tests the top modules first and moves to the lower modules one at a time. -------------------------------------------------------------------------------- /L75/Basic concepts of testing/4.txt: -------------------------------------------------------------------------------- 1 | System testing is the test that checks the entire application. 2 | 3 | System testing is test that is done before the end user is given the application to test if it meets his expectations. -------------------------------------------------------------------------------- /L75/Basic concepts of testing/5.txt: -------------------------------------------------------------------------------- 1 | The acceptance testing is the last level in testing. 2 | 3 | 4 | Acceptance testing is also known as UAT. 5 | 6 | 7 | User tests the application to see if the application/product meets the business requirements. -------------------------------------------------------------------------------- /L75/Why testing is required/1.txt: -------------------------------------------------------------------------------- 1 | The process/method of finding bugs/errors in a software application developed, to ensure that the application meets the user's requirement is called software testing. 2 | 3 | 4 | Software testing is broadly categorised into two types - functional testing and non-functional testing. -------------------------------------------------------------------------------- /L75/Why testing is required/2.txt: -------------------------------------------------------------------------------- 1 | Testing in early software days was just debugging. 2 | 3 | 4 | Glenford Myers was the person who first started to have a team who separated from coders to testers. 5 | 6 | Every type of testing has a specific purpose and provides value to the end product. -------------------------------------------------------------------------------- /L76/1.txt: -------------------------------------------------------------------------------- 1 | The unittest is a standard library provided by Python for unit testing. 2 | 3 | A unit testing framework is used for automations of tests. 4 | 5 | A test case is the individual unit of testing. -------------------------------------------------------------------------------- /L76/2.txt: -------------------------------------------------------------------------------- 1 | A unittest module is used for writing and running test. 2 | 3 | unitest.TestCase is a base class which implements the interface methods needed to run the test runner. 4 | 5 | An instance of testcase provides three groups of methods each for a specific. purpose. -------------------------------------------------------------------------------- /L76/3.txt: -------------------------------------------------------------------------------- 1 | A unittest testcase in Python can be run using the CLI. 2 | 3 | 4 | In Python unittest, We can run tests on multiple modules at once. 5 | 6 | 7 | All the modules, classes and methods that need to be tested can go in a single statement. -------------------------------------------------------------------------------- /L76/4.txt: -------------------------------------------------------------------------------- 1 | An assertion is used to verify if an assumption made by the programmer is valid or not. 2 | 3 | 4 | Disabling of assertions is done by using the -O flag (capital O) . 5 | 6 | 7 | Assertion methods can raise Assertion Errors too. -------------------------------------------------------------------------------- /L76/5.txt: -------------------------------------------------------------------------------- 1 | To make a testcase we subclass TestCase or FunctionTestCase of unittest module. 2 | 3 | 4 | A testcase methods when written, the name of the method should be prefixed with test. -------------------------------------------------------------------------------- /L76/6.txt: -------------------------------------------------------------------------------- 1 | Test suite is a class in the unittest module. 2 | 3 | 4 | This class is an interface that specifies the test runner of how to run this suite as a testcase. 5 | 6 | Objects of TestSuite are used to aggregate the tests into groups that can be run together. -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/1.py: -------------------------------------------------------------------------------- 1 | import array as a 2 | arr=a.array('i',[]) 3 | sum = 0 4 | n = int(input()) 5 | for i in range(n): 6 | # fill the required code here 7 | r=int(input()) 8 | arr.append(r) 9 | for i in arr: 10 | # arr[i]+=arr[i]+1# Complete the missing code in the given for loop 11 | # fill the required code here 12 | sum+=i 13 | print ('Sum of the array is ', sum) -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/2.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | n = int(input("Enter size of the array : ")) 3 | a = arr.array('i',[]) 4 | print("Enter array elements : ") 5 | for i in range(n): 6 | r=int(input()) 7 | a.append(r) 8 | a[0],a[-1]=a[-1],a[0] 9 | print("After swapping the array elements : ") 10 | for i in a: 11 | print(i,end=' ') 12 | """ 13 | Write remaining logic of the code. 14 | Use array a for input and printing results 15 | 16 | """ 17 | -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/3.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | a = arr.array('i',[]) 3 | n = int(input("Enter size : ")) 4 | print("Enter elements : ") 5 | ''' 6 | Write remaining code here 7 | Use the array package imported 8 | 9 | ''' 10 | # res=[] 11 | for i in range(n): 12 | k=int(input()) 13 | a.append(k) 14 | # prin0t (res) 15 | print("Enter an integer value : ") 16 | l=int(input()) 17 | for i in range(n): 18 | if a[i]==l: 19 | print('Matching indexes:',i) 20 | 21 | -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/4.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | a = arr.array('i',[]) 3 | n = int(input("Enter size of the array : ")) 4 | print("Enter array elements : ") 5 | 6 | flag0=False 7 | flag1=False 8 | flag2=False 9 | for i in range(n): 10 | k=int(input()) 11 | if k==1: 12 | flag0=True 13 | elif k==2: 14 | flag1=True 15 | elif k==3: 16 | flag2=True 17 | # a.append(k) 18 | # for i in range(n): 19 | # if a[i]==1 and a[i]==2 and a[i]==3: 20 | if flag0==True and flag1==True and flag2==True: 21 | print("true") 22 | # elif a[i]!= 1 and a[i]!= 2 and a[i]!=3: 23 | else: 24 | print("false") 25 | # break 26 | -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/5.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | a = arr.array('i',[]) 3 | n = int(input("Enter size : ")) 4 | print("Enter elements : ") 5 | 6 | ''' 7 | Complete your code here 8 | Use array a using array package imported above 9 | ''' 10 | for i in range(n): 11 | k=int(input()) 12 | a.append(k) 13 | l=int(input("Enter an integer value : ")) 14 | def count(first,l): 15 | count=0 16 | for ele in a: 17 | if (ele==l): 18 | count=count+1 19 | return count 20 | print(l," is repeated ",count(a,l), " times") 21 | # break -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/6.py: -------------------------------------------------------------------------------- 1 | # import array as arr 2 | # a = arr.array('i',[]) 3 | # n = int(input("Enter size of the array :")) 4 | # print("Enter array elements : ") 5 | 6 | ''' 7 | write your solution here 8 | use array package imported as arr 9 | ''' 10 | import array as arr 11 | a=arr.array('i',[]) 12 | n=int(input("Enter size of the array: ")) 13 | print("Enter array elements: ") 14 | for i in range(n): 15 | k=int(input()) 16 | a.append(k) 17 | p=int(input("Enter an integer value: ")) 18 | if a[0]==p or a[-1]==p: 19 | print("true") 20 | else: 21 | print("false") -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/7.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import bisect 3 | '''This program prints the longest ascending se quence(as a array) 4 | in a given array''' 5 | import array as arr 6 | # L1 is a array of integer elements scanned speparated with spaces 7 | L1=arr.array('i',[int (x) for x in input("Please enter a list of numbers separated by space: ").split()]) 8 | print(L1) 9 | def longest(nums): 10 | sub=[] 11 | for i in range(len(nums)): 12 | temp=nums[i:] 13 | val=[] 14 | max=-9999 15 | for i in temp: 16 | if i>max: 17 | val.append(i) 18 | max=i 19 | sub.append(val) 20 | sub.sort(key=len) 21 | m=len(sub[-1]) 22 | for i in sub: 23 | if len(i)==m: 24 | return i 25 | # return sub[-1] 26 | a=longest(L1) 27 | L2=arr.array('i',a) 28 | print(L2) 29 | 30 | 31 | -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/8.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | def valley(l): 3 | 4 | if (len(l)<3): 5 | return False 6 | up_count =1 7 | low_count =1 8 | for i in range(0, len(l)-1): 9 | if l[i]>l[i+1]: 10 | if low_count >1: 11 | 12 | return False 13 | up_count = up_count +1 14 | if l[i] 1 and low_count > 1: 19 | return True 20 | else: 21 | return False 22 | 23 | 24 | ''' 25 | Write your driver code to scan array with space separated elements 26 | Write code to print the array 27 | 28 | ''' 29 | lst=arr.array('i',[int(x) for x in input("Input Integers separated by spaces: ").split()]) 30 | # ("Input Integers separated by spaces: ")) 31 | print("Entered array is: ",lst) 32 | # for i in range(len(k)): 33 | # ls1.append(k) 34 | # lst.append(val) 35 | # print("Entered array is:",lst) 36 | print(valley(lst)) -------------------------------------------------------------------------------- /L77/Coding Exercises Using Arrays/9.py: -------------------------------------------------------------------------------- 1 | # Type you complete solution to run the test cases 2 | a,b=map(int,input('Enter row and column sizes : \n').split()) 3 | print('Enter ',a*b,' values :') 4 | c=[] 5 | e=[] 6 | for i in range(a): 7 | d=(list(map(int,input().split()))) 8 | f=max(d) 9 | c.append(f) 10 | e.append(d) 11 | print("The given matrix is") 12 | for i in e: 13 | for j in i: 14 | print(j,end=" ") 15 | print() 16 | for i in range(len(c)): 17 | print('Largest of row - ',i,' elements = ',c[i]) -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/1.py: -------------------------------------------------------------------------------- 1 | # Type your code here 2 | import array as arr 3 | a = arr.array('i', [10, 30, 50, 90]) 4 | 5 | #Fill the line below to print the element at the 0th index 6 | print("first element at index 0 i.e. a[0]:", a[0] ) 7 | 8 | #Fill the line below to print the second element in the array. 9 | print("second element at index 1 i.e. a[1]:", a[1] ) 10 | 11 | #Fill the line below to print the third element in the array. 12 | print("third element at index 2 i.e. a[2]:", a[2] ) 13 | 14 | #Fill the line below to print the fourth element in the array. 15 | print("fourth element at index 3 i.e. a[3]:", a[3] ) 16 | 17 | #Fill the line below to print the last element in the array. 18 | print("last element in the array can be accessed as a[-1]:", a[-1] ) 19 | 20 | #Fill the line below to print the second last element in the array. 21 | print("Second last element in the array can be accessed as a[-2]:", a[-2] ) -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/2.txt: -------------------------------------------------------------------------------- 1 | We can store homogenous data in the list data structure but array can only store homogenous data 2 | 3 | 4 | List can store homogenous as well as heterogenous data depending upon the requirement of the problem 5 | 6 | As arrays are not available inbuilt in python so we import array module explicitly but for list their is no need to import any explicit module, -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/3.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | value=arr.array('d',[1.2,2.3,3.4,5.5,7.6,10.8]) 3 | value[0]=0.5 4 | print(value) 5 | value[2:5]=arr.array('d',[4.9,6.9,8.9]) 6 | print(value) 7 | # array('') -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/4.py: -------------------------------------------------------------------------------- 1 | # Type your code here 2 | import array as arr 3 | values=arr.array('d',[1.2,2.3,3.4,5.5,7.6,10.8]) 4 | print("Size of array values is: ",len(values)) 5 | print(values) 6 | del values[2] 7 | print(values) 8 | del values[2:4] 9 | print(values) 10 | -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/5.py: -------------------------------------------------------------------------------- 1 | import array as arr 2 | values1=arr.array('d', [1.2,2.3,3.4,5.5,7.6,10.8]) 3 | values2=arr.array('d',[11.2,12.3,13.4,15.5,17.6]) 4 | print(values1) 5 | print(values2) 6 | values3=arr.array('d') 7 | print(values3) 8 | values3=values1+values2 9 | print(values3) -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/6.py: -------------------------------------------------------------------------------- 1 | from array import * 2 | arr=[[11,21,31,41],[81,91,101,121]] 3 | print("Display elements before performing insertion in 2-D array : ") 4 | print(arr) 5 | arr.insert(1, [5,6,7,8]) 6 | print("Display elements after performing insertion in 2-D array :") 7 | for i in arr: 8 | for j in i: 9 | print(j, end=" ") 10 | print() -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/7.py: -------------------------------------------------------------------------------- 1 | from array import * 2 | arr=[[10,20,30],[40,50,60],[70,80,90]] 3 | print("Array before modification") 4 | for _ in arr: 5 | for i in _: 6 | print(i,end=" ") 7 | print() 8 | arr[1].insert(2,120) 9 | print("Array after modification") 10 | for _ in arr: 11 | for i in _: 12 | print(i,end=" ") 13 | print() -------------------------------------------------------------------------------- /L77/Fundamentals Of Arrays In Python Using Array Module/8.py: -------------------------------------------------------------------------------- 1 | from array import * 2 | arr=[[11,21,31,41],[81,91,101,121]] 3 | print("Display elements before performing deletion's in 2-D array : ") 4 | print(arr) 5 | del(arr[0][2]) 6 | del(arr[1]) 7 | print("Display elements after performing deletion's in 2-D array :") 8 | for i in arr: 9 | for j in arr: 10 | for j in i: 11 | print(j, end=" ") 12 | print() -------------------------------------------------------------------------------- /L78/1.py: -------------------------------------------------------------------------------- 1 | import math 2 | a=int(input("Enter the x coordinate of first point: ")) 3 | b=int(input("Enter the y coordinate of first point: ")) 4 | c=int(input("Enter the x coordinate of second point: ")) 5 | d=int(input("Enter the y coordinate of second point: ")) 6 | k=((a-c)**2+(b-d)**2)**0.5 7 | print("Distance is:",k) -------------------------------------------------------------------------------- /L78/10.py: -------------------------------------------------------------------------------- 1 | size=int(input("Enter size of int-list: ")) 2 | st=int(input("Enter size of string-list: ")) 3 | res=[] 4 | for i in range(1,size+1): 5 | a=int(input("Enter int for int-list: ")) 6 | res.append(a) 7 | res1=[] 8 | for j in range(1,st+1): 9 | b=(input("Enter string for string-list: ")) 10 | res1.append(b) 11 | dic={} 12 | t=dict(zip(res,res1)) 13 | print(t) 14 | -------------------------------------------------------------------------------- /L78/11.py: -------------------------------------------------------------------------------- 1 | a=input('Enter the filename: ') 2 | b=input('Enter the character to be searched: ') 3 | c=open(a,'r') 4 | count=0 5 | d=c.read() 6 | for i in d: 7 | if i==b: 8 | count+=1 9 | print(b,'appears',count,'times in file') 10 | print('The type of file:',type(c)) -------------------------------------------------------------------------------- /L78/12.py: -------------------------------------------------------------------------------- 1 | a=input('Enter file name: ') 2 | b=open(a,'r') 3 | c=b.readlines() 4 | c=c[::-1] 5 | for i in c: 6 | print(i.rstrip()) -------------------------------------------------------------------------------- /L78/13.py: -------------------------------------------------------------------------------- 1 | a=input('Enter file name: ') 2 | file=open(a,"rt") 3 | data=file.read() 4 | chr1=len(data) 5 | words=data.split() 6 | def counter(fname): 7 | num_words=0 8 | num_lines=0 9 | num_charc=0 10 | with open(a,'r') as f: 11 | for line in f: 12 | num_lines +=1 13 | word ='Y' 14 | # for letter in line: 15 | # if (letter != ' ' and word =='Y'): 16 | # num_words+=1 17 | # word='N' 18 | # for line1 in f: 19 | # words=line1.split() 20 | # num_words+=len(words) 21 | # data= 22 | print("Lines =",num_lines) 23 | # print("words =",len(words)) 24 | # print("Characters =",num_charc) 25 | if __name__=='__main__': 26 | fname=a 27 | try: 28 | counter(fname) 29 | except: 30 | print('File not found') 31 | 32 | print("words =",len(words)) 33 | print("Characters =",chr1) 34 | -------------------------------------------------------------------------------- /L78/14.py: -------------------------------------------------------------------------------- 1 | 2 | a,b,c=map(int,input("Enter x, y, r of ball-1: ").split()) 3 | d,e,f=map(int,input("Enter x, y, r of ball-2: ").split()) 4 | dis=c+f 5 | cal=((a-d)**2+(b-e)**2)**0.5 6 | if dis0: 3 | print(n) 4 | n-=1 5 | print("good bye..!") -------------------------------------------------------------------------------- /L78/6.py: -------------------------------------------------------------------------------- 1 | def fibbo(n): 2 | lis=[0,1] 3 | a=0 4 | b=1 5 | count=2 6 | while True: 7 | a=a+b 8 | if countnum2}') 6 | # Print Is num1 less than num2. 7 | print(f'Is {num1} less than {num2} = {num1=num2}') 16 | -------------------------------------------------------------------------------- /L9/Comparison Operators/2.py: -------------------------------------------------------------------------------- 1 | # Comparision Operators >, <, ==, !=, >=, <= on numbers 2 | a=int(input('num1: ')) 3 | b=int(input('num2: ')) 4 | print(f'Is {a} greater than {b} = {a>b}') 5 | print(f'Is {a} less than {b} = {a=b}') 9 | print(f'Is {a} less than or equal to {b} = {a<=b}') 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /L9/Comparison Operators/3.py: -------------------------------------------------------------------------------- 1 | # write your code here 2 | a=input('str1: ') 3 | b=input('str2: ') 4 | print(f'Is {a} greater than {b} = {a>b}') 5 | print(f'Is {a} less than {b} = {a=b}') 9 | print(f'Is {a} less than or equal to {b} = {a<=b}') 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /L9/Comparison Operators/4.py: -------------------------------------------------------------------------------- 1 | a = input("str1: ") 2 | b = input("str2: ") 3 | print(f'Is {a} greater than {b} = {a>b}') 4 | print(f'Is {a} less than {b} = {a=b}') 8 | print(f'Is {a} less than or equal to {b} = {a<=b}') 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

CodeTantra-python-placement 2 |

3 | 4 | 5 | 6 | ![Codetantra Logo](https://user-images.githubusercontent.com/110342305/201940666-1012a318-063a-4173-a868-fd47eefdec06.png) 7 | 8 | ![Visitors](https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fgithub.com%2Fwarriorwizard%2FCodeTantra-python-placement&label=%F0%9F%91%BB%20%3A%20&labelColor=%23000000&countColor=%23000000&style=flat-square) 9 | 10 |

11 | 12 |

NIET CODETANTRA PLACEMENT PYTHON 2022 13 |
14 |
15 | Hello Geeks! 16 |
17 |
18 | 19 |
20 |
21 | 22 | Happy coding :) 23 | 24 | 25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | 36 | 37 | 38 | special thanks to @DevilANANDGupta for contributing to this repo 39 | --------------------------------------------------------------------------------