P

@Puvi0707

Calculate sqrt of a no

Python
4 years ago
X=Float(Input("Enter a number: ")) X_sqrt=x**0.5 Print(" Square Root of %0.2f is %0.2f %"(x,x_sqrt))

Calculate pow of x,n

Python
4 years ago
num= int(input("Enter the number: ")) n=int(input("Till which power to calculate?")) result = 1 for i in range(n): result =result *num print (num, "raised to the power",n,"is", result)

Gcd of 2 nos

Python
4 years ago
num1= int(input("Enter the two numbers:")) num2= int(input("Enter the two numbers:")) if(num1>num2): dividend =num1 divisor =num2 else: dividend = num2 divisor= num1 while(divisor!=0): remainder =dividend %divisor

Create a even nos

Python
4 years ago
num_list=[ ] for i in range(1,11): num_list.append(1) print("Original List:", num_list) for i, index in enumerate (num_list): if(i%2==0): del num_list[index] print("List after deleting even numbers: ",num_list)

Country

Python
4 years ago
country=["Brazil","India", "China", "Russia", "Sri Lanka"] is_member=input("Enter the name of country:") if is_member in country: print(is_member, "has also joined BRICS") else: print(is_member, "is not a member of BRICS")

List of finding squares using filter

Python
4 years ago
def square(x): return(x**2) squares = [ ] squares= list(filter(square, range(1, 11))) print("List of squares in the range 1-10 =", squares) Sum= 0 for i in squares: Sum+=i print("Sum of squares in the range 1-10 = ", sum)

Divisible by 2 nd 4

Python
4 years ago
Div 2,4=[] for i in range(2,22): if(i%2==0 or i%4==0): Div 2 ,4.append(1) print(div_2_4)

Calculate sum of values

Python
4 years ago
def add(x,y): return x+y List=[1,2,3,4,5] print("Sum of values in list) Print(functools.reduce(add, num list))

Area of the circle

Python
4 years ago
radius = float(input("Enter the radius of the circle: ")) area = 3.14*radius*radius circumference = 2*3.14*radius print("AREA= " +str(round(area,2))+"\t CIRCUMFERENCE ="+str(round(circumference,2)))

Implementing variables

Python
4 years ago
def f(): print (s) S = ("I love Geeks forgeeks") f()

Loop concept using python nested loop

Python
4 years ago
even_list = [] for item in range(1, 11): while item % 2 == 0: even_list.append(item) break print("Even Numbers: ", even_list)

Loop concept using python while loop

Python
4 years ago
count=0 while (count<3): count=count+1 print("Hello Geek")

Loop concept using python for loop

Python
4 years ago
list = ["geeks", "for", "geeks" ] for index in range (len (list)) : print list[index]

Print the pattern

Python
4 years ago
1 22 333 4444 55555 N=5 for i in range(1,N+1): for k in range(N,i,-1): print("", end=" ") for j in range(1,i+1):

Print the pattern

Python
4 years ago
1 22 333 4444 55555 N=5 for i in range(1,N+1): for k in range(N,i,-1): print(1, end" ") print(", ends ) for j in range(1,i+1): print()

Leap year or not

Python
4 years ago
year=int(input ("Enter any year : ")) if((year%4-8 and year %100!=0) or (year%400 == 0)): print("Leap Year") else: print("Not a Leap Year")

Swapping of 2 nos

Python
4 years ago
def swap(a,b): a,b = b,a print("After swap : ") print("First number = ",a) print("Second number = ",b) a input("\n Enter the first number: ") b=input("\n Enter the second number: ") print("Before swap : ") print("First number = ",a) print("Second nu

Avg of 2nos and print the deviation

Python
4 years ago
num1=int (input("Enter the first number: ")) num2=int (input("Enter the second number: ")) avg=(numi+num2)/2 dev1=num1-avg dev2=num2-avg print("AVERAGE = ", avg) print("Deviation of first num=",devi) print("Deviation of second num=",dev2).

Farenheit into degree

Python
4 years ago
fahrenheit float (input("Enter the temperature in fahrenheit : ")) celsius = (0.56)*(fahrenheit-32) print("Temperature in degrees celsius = ", celsius)

Calculate the area of the circle

Python
4 years ago
radius float(input("Enter the radius of the circle: ")) area = 3.14 radius radius circumference = 2*3.14*radius print("AREA "+str(round(area, 2))+"\t CIRCUMFERENCE = "str(round(circumference.2)))