Skip to content

Commit a07c069

Browse files
committed
test some python problems
1 parent 9cf5146 commit a07c069

15 files changed

+99
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name = input()
2+
print("Hello, "+name)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
a, b, c, d, e = input().split()
2+
3+
print(a)
4+
print(b)
5+
print(c)
6+
print(d)
7+
print(e)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
num1, num2 =map(int, input().split())
2+
3+
print(f"{num1} + {num2} = {num1+num2}")
4+
print(f"{num1} * {num2} = {num1*num2}")
5+
print(f"{num1} - {num2} = {num1-num2}")
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
a, b, c, d = map(int, input().split())
2+
3+
x= (a*b)-(c*d)
4+
print(f"Difference = {x}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
by=3.141592653
2+
x=float(input())
3+
print(by*x*x)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x,y=map(int, input().split())
2+
3+
print(f"{x%10 + y%10}")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x = int(input())
2+
3+
sum = (x * (x + 1)) // 2
4+
5+
print(sum)

c++ #1 (data_type)/H. Two numbers.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import math
2+
3+
x,y = map(int, input().split())
4+
5+
print(f"floor {x} / {y} = {math.floor(x/y)}")
6+
print(f"ceil {x} / {y} = {math.ceil(x/y)}")
7+
print(f"round {x} / {y} = {round(x/y)}")
8+
# the code will not pass cuz this problem built for c++ code not python cuz
9+
# round if take value like 2.5 in c++ will output 3 and in python will be 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
x,y = map(int, input().split())
2+
3+
if x>=y:
4+
print("Yes")
5+
else:
6+
print("No")

c++ #1 (data_type)/J. Multiples.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
x, y= map(float, input().split())
2+
3+
if x%y == 0:
4+
print("Multiples")
5+
elif y%x == 0:
6+
print("Multiples")
7+
else:
8+
print("No Multiples")

c++ #1 (data_type)/K. Max and Min.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
x,y,z = map(int, input().split())
2+
3+
print(f"{min(x,y,z)} {max(x,y,z)}")

c++ #1 (data_type)/L. The Brothers.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
x1,x2 = map(str, input().split())
2+
z1,z2 = map(str, input().split())
3+
4+
if x2 == z2:
5+
print("ARE Brothers")
6+
else:
7+
print("NOT")

c++ #2 (loops)/A. 1 to N.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
x= int(input())
2+
3+
for i in range(1,x+1):
4+
print(i)

c++ #2 (loops)/B. Even Numbers,py.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
x= int(input())
2+
y=True
3+
4+
for i in range(1,x+1):
5+
if i%2==0:
6+
print(i)
7+
y=False
8+
9+
if y==True:
10+
print(-1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
x= int(input())
2+
numbers = list(map(int, input().split()))
3+
4+
even=0
5+
odd=0
6+
position=0
7+
negative=0
8+
9+
for i in numbers:
10+
11+
if i%2==0:
12+
even+=1
13+
else: odd+=1
14+
if i>0:
15+
position+=1
16+
elif i<0:
17+
negative+=1
18+
19+
print(f"Even: {even}")
20+
print(f"Odd: {odd}")
21+
print(f"Positive: {position}")
22+
print(f"Negative: {negative}")
23+

0 commit comments

Comments
 (0)