DAY 4 Exercises

Practice. 1
"" "
Analyzing prime Version 0.1 author Luo Xu as " "" Number= int (INPUT ('Enter a positive integer:')) A=0 forXinRange (2, Number): IFNumber% X ==0 : A= A +. 1 IFA ==0: Print('the number is prime') the else: Print("this number is not prime')
"" " 
Analyzing primes two 
Version 0.1 
author Luo Xu as 
" "" 
Number = int (INPUT ( ' Enter a positive integer ' )) 
is_prime = True
 for X in Range (2, Number ):
     IF Number <= 0:
         Print ( ' ERRO, this is not a natural number greater than zero ' )
     elif number% X == 0: 
        is_prime = False
         BREAK 
Print (is_prime)
2 Practice
"" "
greatest common divisor and the least common multiple Version 0.1 author to Luo Xu " "" A= int (INPUT ('Enter the first number A:')) b= int (INPUT ('Enter the first number b :')) m=max (A, B) n-=min (A, B) forXinRange (2, m): IFm X% == 0andn-% X ==0: P=X Q= n-* m /P Print('the greatest common divisor of% d, the least common multiple of D%'% (P, Q))
Practice 3
The triangular pattern is printed as follows
 *
 ** *** **** ***** * ** *** **** ***** * *** ***** ****** * *********
  

row = int(input('请输入行数: ')) for i in range(row): for _ in range(i+1): print('*',end='') print() for i in range(row): for j in range(row): if j<row-i-1: print(' ',end='') else: print('* ' , End = ' ' ) Print () for I in Range (Row): for J in Range (2 * Row-. 1 ): IF I + J> = Row-. 1 and I> = J-Row +. 1 : Print ( ' * ' , End = '' ) the else : Print ( ' ' , End = '' ) Print ()
"" "
Videos, and column functions obtained relationship determination condition
" ""

 

Guess you like

Origin www.cnblogs.com/luoxucheng97/p/11234138.html