1. Enter two odd numbers n,m
use for Statement writing loop , Calculate from n reach m The sum of all odd numbers between
Input / output example
Input and output
Examples 11,1136
Answer code :
m, n = tuple([int(i) for i in input().split(',')]) print(sum(i for i in
range(m, n + 1) if i % 2))
Test case :
2.
input data n, use while sentence , reach 1+2+3+...+n And
Input / output example
Input and output
Examples 136
Answer code :
n=int(input()) S=0 i=1 while i<=n: S=S+i i=i+1 print(S)
Test case :
3.
input data n and m
use while Statement calculation n reach m All data and
Input / output example
Input and output
Examples 13,512
Answer code :
s = input() l = s.split(',') n = int(l[0]) m = int(l[1]) sum = 0 while n <= m:
sum = sum + n n = n + 1 print(sum)
Test case :
4.
Enter a data , Determine whether it is a prime number
If it is , Then output “ It's a prime ”, Otherwise output “ Not prime ”
Input / output example
Input and output
Examples 1
3
6
It's a prime
Not prime
Answer code :
x = eval(input()) for i in range(2,x): if x%2==0: print(" Not prime ") break else:
print(" It's a prime ") break
Test case :
Technology