PROGRAM 1:
CODE:
r=int(input())
spaces= r-1 #total spaces at first
for i in range(0, r):
for j in range(0, spaces):
print(end=" ")
spaces = spaces - 1#decrease space
for j in range(0, i+1):
print("* ", end="") #to print star
print("") #for new line
CODE'S SCREENSHOT:
OUTPUT:
PROGRAM 2:
CODE:
a=float(input())
b=float(input())
c=float(input())
#for sorting a,b and c which are 3 sides of triangle
#s1>s2>s3
s1 = min(a, b, c) #minimum of all 3 sides
s3 = max(a, b, c) #maximum of all 3 sides
s2 = (a+ b+ c) - s1 - s3 #all 3 sides sum - max side -min side
#c2<b2<a2
c2=s1*s1
b2=s2*s2
a2=s3*s3
if(a2>(b2+c2)):
print("OBTUSE")
elif(a2<(b2+c2)):
print("ACUTE")
else:
print("RIGHT")
CODE'S SCREENSHOT:
OUTPUT:
PROGRAM 3:
CODE:
n=int(input()) #inputting number
if n>1:
for d in range(2,n):
if(n%d)==0: #if any divison found than not prime
print("NOT PRIME")
break
else: #else prime
print("PRIME")
else: #number less than or equal to 1 are not prime
print("NOT PRIME")
CODE'S SCREENSHOT:
OUTPUT:
PROGRAM 4:
CODE:
x=float(input()) #inputting x coordinate
y=float(input()) #inputting y coordinate
if(x>=0 and y>=0):# checking for Q1 x+ y+
print("Q1")
elif(x<0 and y>=0):# checking for Q2 x- y+
print("Q2")
elif(x<0 and y<0):# checking for Q3 x- y-
print("Q3")
else: # automatically Q4 x+ y-
print("Q4")
CODE'S SCREENSHOT:
OUTPUT:
PROGRAM 5:
CODE:
r=int(input())
spaces= 2*r-2 #total spaces at first
for i in range(0, r):
for j in range(0, spaces):
print(end=" ")
spaces = spaces - 2#decrease space
for j in range(0, i+1):
print("* ", end="") #to print star
print("") #for new line
CODE'S SCREENSHOT:
OUTPUT:
I hope I solved all your queries, In case of doubt feel free to ask in the comment section.
Q1 SUMMER2020- nts python language Example Write a program to read an integer r then print...
# Write PYTHON programs that read a sequence of integer inputs and print # a. The smallest and largest of the inputs. # b. The number of even and odd inputs. # c. Cumulative totals. For example, if the input is 1 7 2 9, the program should print # 1 8 10 19. # d. All adjacent duplicates. For example, if the input is 1 3 3 4 5 5 6 6 6 2, the # program should print...
Write a program(Python language for the following three questions), with comments, to do the following: Ask the user to enter an alphabetic string and assign the input to a variable str1. Print str1. Check if str1 is valid, i.e. consists of only alphabetic characters. If str1 is valid Print “<str1> is a valid string.” If the first character of str1 is uppercase, print the entire string in uppercase, with a suitable message. If the first character of str1 is...
write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : Alex got a sequence of n integers a1,a2,…,an as a birthday present. Alex doesn't like negative numbers, so he decided to erase the minus signs from all negative numbers. As a result, he got a sequence of non-negative numbers. Print the resulting sequence. For example, if the sequence is 1, 5, -3, 4,...
python language Primes Write a program primes.py that reads a positive integer from standard input, and determines whether or not the number is prime A prime number is a positive integer that is greater than 1, an e can be divided exactly (without leaving a rerm or itself 1 $ python3 primes. py 2 one positive integer please: 21 3 21 is not prime! 5 S python3 primes. py 6 one positive integer please 7 23 is prime
write the solution of the program by python 3 language : I need the program using list : You are given a non-decreasing sequence of n positive integers a1,a2,…,an. Print the number of distinct values in the sequence. For example, if the sequence is 1,2,2,2,3,4,4,5,7,10, the answer is 6 since distinct values are 1,2,3,4,5,7,10. Input The first line contains a positive integer n (1≤n≤1000) — the length of the sequence. The second line contains n space-separated positive integers a1,a2,…,an (1≤ai≤1000)...
write the solution of the program by python 3 language : I need the program using list : You are given a sequence of n positive integers a1,a2,…,an, where n is even. Swap adjacent elements in the given sequence and print the resulting sequence: a2,a1,a4,a3,a6,a5,… Input The first line contains a positive even integer n (2≤n≤1000) — the length of the sequence. The second line contains n space-separated integers a1,a2,…,an (1≤ai≤1000) — the elements of the sequence. Output Print n...
write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other in the sequence. Input The first line contains an integer n...
write the solution of the program by python 3 language : I need the program using list or string or loops (while and for) or if,elif,else : i have 15 min to submit the solution please help me You are given a sequence of n non-zero integers a1,a2,…,an. Determine if the given sequence contains a pair of adjacent elements of the same sign (both negative or both positive). Two elements are called adjacent if they stand next to each other...
python nts) Given L = [4, 5, 6, 81, write instructions for the following: Example: Print first number in the list Print the last number in the list Change L to (4,5, 6,8,20] by appending the integer 20 to L Reverse the elements in the list L Change L to ['new', 4, 5, 6, 8] print(L[O]) priet (l ) Ω4.20 points) Given L-4, [5, 6], 7], what is the result of the following: a) LII I1 b) LI-21 c) L.pop...
Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the user to enter a string which is subsequently displayed in uppercase. It is important to first ensure that string to be converted is in the a-z range. The program does not recognize any space, symbols or any kind of punctuation marks. Any time the user enters any of this character the program is going to repeatedly ask for the...