Calendar Module python
Calendar Module The calendar module allows you to output calendars and provides additional useful functions for them. class calendar.TextCalendar([firstweekday]) This class can be used to generate plain text calendars. Sample Code >>> import calendar >>> >>> print calendar.TextCalendar(firstweekday=6).formatyear(2015) 2015 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su
View Solution →Exceptions python
Exceptions Errors detected during execution are called exceptions. Examples: ZeroDivisionError This error is raised when the second argument of a division or modulo operation is zero. >>> a = '1' >>> b = '0' >>> print int(a) / int(b) >>> ZeroDivisionError: integer division or modulo by zero ValueError This error is raised when a built-in operation or function receives an argument that has the right type but an inappropriate value. >>> a = '1' >>> b = '#' >>> print int(a) / i
View Solution →Incorrect Regex python
You are given a string S. Your task is to find out whether S is a valid regex or not. Input Format The first line contains integer T, the number of test cases. The next T lines contains the string S. Constraints 0<T<100 Output Format Print "True" or "False" for each test case without quotes.
View Solution →Classes: Dealing with Complex Numbers python
For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct up to two decimal places. Input Format One line of input: The real and imaginary part of a number separated by a space. Output Format For two complex numbers C and D, the output should be in the following sequence on separate lines: 1. C+D 2. C-D 3. C*D
View Solution →Class 2 - Find the Torsional Angle python
You are given four points A,B,C and D in a 3-dimensional Cartesian coordinate system. You are required to print the angle between the plane made by the points A,B,C and B,C,D in degrees(not radians). Let the angle be PHI. Cos(PHI) = (X.Y) / |X| |Y| where X=AB x BC and Y= BC x CD. Here, X.Y means the dot product of X and Y, and AB x BC means the cross product of vectors AB and BC. Also, AB = B-A. Input Format One line of input containing the space separated floating number values
View Solution →