"Daily Code question 001"-Python Basics Review

Source: Internet
Author: User

Question 001-1: Please enter a three integer a,b,c to determine whether you can make them into a triangle of three side lengths. Output Yes and area if possible, otherwise the output no

A = float (input ())
b = float (input ())
c = Float (input ())

If a > 0 and b > 0 and C > 0: #判断边长是否为正
if (A + B > C) and (A + C > B) and (B + C > a): #判断是否可以为三角形
p = (A + B + C)/2.0
S = (p* (p-a) * (p-b) * (p-c)) **0.5 #面积, Helen Formula
Print ("YES, side length: a = {},b = {},c = {}, area: {}". Format (a,b,c,s))
Print ("NO")
Print ("NO")

Question 001-2: The number of reversible primes is to reverse the order of the number of numbers of a prime, and still be prime, please program and output a reversible prime within 200

Note: 1 is not a prime or a composite.

Def getrenums (n):
      if ((n//100 ==0) & (N//10 ==0)):
          &N Bsp NUM1 = n
            NUM2 = n
      &NBS P     if ((n//100 ==0) & (N//10!=0):
                 NUM1 = n
                 NUM2 = n%10 * + N//10
      &NBS P    else:
                NUM1 = n
        &NBS P       NUM2 = n%100%10 * +n//10%10*10 +n//100
     return num1,num2

For n in range (2,200,1):
num1,num2 = Getrenums (n)
DEVN1 = 0
DEVN2 = 0
For I in Range (2,num1,1):
if (num1%i ==0):
DEVN1 = devn1+1
For I in Range (2,num2,1):
if (num2%i ==0):
DEVN2 = devn2+1
if ((devn1==0) & (devn2==0)):
Print (n)

"Daily Code question 001"-Python Basics Review

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.