Question

Q1 SUMMER2020- nts python language Example Write a program to read an integer r then print a triangle with r number of rows u9 - عام python language Course Information o Course Material Assignments o example input Lab Exercises Quizzes Result 7.0 ACUCourse Course Material Q3 Assignments python language Lab Exercises example input Quizzes 8 Result Exam NOT PRIME حة الرئيسيةCoat الكفاءات Q4 python language و العلامات pleo سؤال 4 A Course Information C Write a program that reads two floating valuesQ5 Course Informa python language example input Course Ma Result Assign * Lab 5 سؤال 5 Read an integer r, then print a right

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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:

1 2 الا 4 5 r=int(input) spaces= r-1 #total spaces at first for i in range(0, 1): for j in range(0, spaces): print(end= ) s

OUTPUT:

Input Output 10 G

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:

1 a=float(input()) 2 b=float(input()) 3 c=float(input()) 4 #for sorting a,b and c which are 3 sides of triangle 5 #s1>s2>53 6

OUTPUT:

Input Output ACUTE 7.0 7.0 5.0

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:

1 2 3 4 5 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 prin

OUTPUT:

Input Output 8 NOT PRIME

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:

1 x=float(input()) #inputting x coordinate y=float(input()) #inputting y coordinate 2 3 4 5 6 7 if(x>=0 and y>=0):# checking

OUTPUT:

Input Output 04 4.5 -2.2

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:

N m n 0 0 1 reint(input() spaces= 2*r-2 #total spaces at first for i in range(0, r): 4 for j in range(0, spaces): print(end=

OUTPUT:

Input Output 10

I hope I solved all your queries, In case of doubt feel free to ask in the comment section.

Add a comment
Know the answer?
Add Answer to:
Q1 SUMMER2020- nts python language Example Write a program to read an integer r then print...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • # Write PYTHON programs that read a sequence of integer inputs and print # a.  The...

    # 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:   ...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT