├── README.md ├── alpha_sort.py ├── area_of_triangle.py ├── factorial.py ├── greatest_of_three.py ├── list_square_sum.py ├── no_of_days_month.py ├── pattern_triangle.py └── string_rev.py /README.md: -------------------------------------------------------------------------------- 1 | # Newpythonbot 2 | this repository contains about python language 3 | -------------------------------------------------------------------------------- /alpha_sort.py: -------------------------------------------------------------------------------- 1 | a = list(input("Enter strings separated by spaces: ").split()) 2 | print(a) 3 | # Sorting the list alphabetically 4 | sorted_list = sorted(a) 5 | print(sorted_list) 6 | 7 | 8 | -------------------------------------------------------------------------------- /area_of_triangle.py: -------------------------------------------------------------------------------- 1 | a=int(input("enter the value of side 'a':")) 2 | b=int(input("enter the value of side 'b':")) 3 | c=int(input("enter the value of side 'c':")) 4 | s=(a+b+c)/2 5 | area=(s*(s-a)*(s-b)*(s-c))**0.5 6 | print("Area of the triangle is :",area) 7 | 8 | -------------------------------------------------------------------------------- /factorial.py: -------------------------------------------------------------------------------- 1 | def fact(x): 2 | if x==1: 3 | return 1 4 | else: 5 | return(x*fact(x-1)) 6 | n=int(input("enter the number:")) 7 | print(fact(n)) 8 | 9 | -------------------------------------------------------------------------------- /greatest_of_three.py: -------------------------------------------------------------------------------- 1 | a=int(input("Enter value of a:")) 2 | b=int(input("Enter value of b:")) 3 | c=int(input("Enter value of c:")) 4 | if a>b and a>c: 5 | print("a is greater") 6 | elif b>a and b>c: 7 | print("b is greater") 8 | elif c>a and c>b: 9 | print("c is greater") 10 | else: 11 | print("All three are eqaul") 12 | 13 | -------------------------------------------------------------------------------- /list_square_sum.py: -------------------------------------------------------------------------------- 1 | #sum of squares of the list 2 | a = list(map(int, input("enter the list:").split())) 3 | print(a) 4 | l=[] 5 | for i in a: 6 | s=i*i 7 | l.append(s) 8 | print(l) 9 | d=sum(l) 10 | print(d) 11 | -------------------------------------------------------------------------------- /no_of_days_month.py: -------------------------------------------------------------------------------- 1 | a=input("enter a month:") 2 | if a=="feb": 3 | print("has 28 days") 4 | elif a in "jan,mar,may,july,aug,oct,dec": 5 | print("has 31 days") 6 | elif a in "april,june,sep,nov": 7 | print("has 30 days") 8 | else: 9 | print("enter a valid month") 10 | 11 | -------------------------------------------------------------------------------- /pattern_triangle.py: -------------------------------------------------------------------------------- 1 | def triangle(n): 2 | k = n - 1 3 | for i in range(0, n): 4 | for j in range(0, k): 5 | print(end=" ") 6 | k = k - 1 7 | for j in range(0, i+1): 8 | print("* ", end="") 9 | print("\r") 10 | n = 5 11 | triangle(n) 12 | -------------------------------------------------------------------------------- /string_rev.py: -------------------------------------------------------------------------------- 1 | #string reverse method by concatenation 2 | n="vishal" 3 | str="" 4 | for i in n: 5 | str=i+str 6 | print("reversed string:",str) 7 | --------------------------------------------------------------------------------