You are on page 1of 151

 Seminar 2-1

 Seminar 4
 Seminar 5
 Seminar 6
 Seminar 7
 Seminar 8
 Seminar 9-2
 Seminar 9-2 Функц нэмэлт дасгал
 Seminar 10
 Seminar 11
 Seminar 12-1
 Seminar 12-2
 Явцын шалгалт 2

Seminar 2-1
Seminar 4 бодлого

n =("The quick brown fox jumps over the lazy dog")

words=n.split( )

a = words[0]

b = words[1]

c = words[2]

d = words[3]

e = words[4]

f = words[5]

g = words[6]

h = words[7]

i = words[8]
n = input()

print("Сайн уу,", n+"!")

a = float(input())
b = float(input())

c = float(input())

s=a+b+c

print(s)

n = float(input())

s = n ** 2

print(s)
r = float(input())

s = 3.14 * (r ** 2)

print(s)
a = float(input())

h = float(input())

s = (1/2) * a * h

print(s)
import math

a = float(input())

b = float(input())

c = float(input())

i = (a + b + c)

p = i/2

q = p*((p-a)*(p-b)*(p-c))

s = math.sqrt(q)

print(s)
n = int(input())

b = n-1

m = n+1

print("Өгөгдсөн тоо ", n, "-н " , "дараагийн тоо бол ",m, ".", sep='')

print("Өгөгдсөн тоо ", n, "-н " , "өмнөх тоо бол ",b, ".", sep='')
N = int(input())

K = int(input())

a = K // N

b=K%N

print("Сурагч тус бүрт:", a, "алим")

print("Сагсанд:", b, "алим")
h1 = int(input())

m1 = int(input())

s1 = int(input())

ts1 = (h1 * 3600) + (m1 * 60) + s1

h2 = int(input())

m2 = int(input())

s2 = int(input())

ts2 = (h2 * 3600) + (m2 * 60) + s2

td = ts2 - ts1

print(td)
import math

a = int(input())

b = int(input())

c = int(input())

a1=math.ceil((a+1)//2)

b1=math.ceil((b+1)//2)

c1=math.ceil((c+1)//2)

s = (a1 + b1 + c1)

print(s)
Seminar 5 бодлого

a=int(input())

s=a%10

print(s)

a=int(input())
b=a//10

c=a%10

print(b,c)

a=int(input())

b=a//10

c=a%10

print(c,b,sep="")
a=int(input())

s=a%100

print(s)

a=int(input())

b=a%100

c=b//10
print(c)

n = int(input())

digit1 = n // 100

digit2 = (n // 10) % 10

digit3 = n % 10

s = digit1 + digit2 + digit3

print(s)
n = int(input())

digit1 = n // 100

digit2 = (n // 10) % 10

digit3 = n % 10

print(digit3, digit2, digit1, sep="")


n = int(input())

n2 = int(input())

digit1 = n // 100

digit2 = (n // 10) % 10

digit3 = n % 10

digit11 = n2 // 100

digit12 = (n2 // 10) % 10

digit13 = n2 % 10

print(digit2, digit12, digit3, digit13, sep="")


n = int(input())

digit1 = n // 100

digit2 = (n // 10) % 10

digit3 = n % 10

print(digit2, digit3, digit1, sep="")


decNum = float(input())

frac = decNum - int(decNum)

print(frac)

import math

n=float(input())

s=n*10

l=math.floor(s % 10)

print(l)
import math

zai = float(input())

ts = float(input())

ds = math.ceil(ts / zai)

print(ds)
m = int(input())

hours = m // 60

minutes = m % 60

print(hours, ":", minutes, sep="")


d = int(input())

c = int(input())

n = int(input())

td = n * d

tc = n * c

tdc=td*100

t=tdc+tc

dt=t//100

rc=t%100

print(dt, "доллар",rc, "цент")


y = int(input())

c = (y - 1) // 100 + 1

print(c, "-р", " зуун", sep="")


H = float(input())

A = float(input())

B = float(input())

if A >= H:

print(1)

else:

d=1

dc = A

while dc < H:
dc -= B

if dc >= H:

break

dc += A

d += 1

print(d, "өдөр")

H = int(input())

M = int(input())

S = int(input())
O = 30 * H + 0.5 * M + (1 / 120) * S

print(O)

a=float(input())

b=(a%30*360/30)

print(b)
Seminar 6 бодлого

n=int(input())

if n<=0:

print("NO")

else:

print("YES")
n=int(input())

if n%2==0:

print("YES")

else:

print("NO")
n=int(input())

if n%2==0:

print("NO")

else:

print("YES")
n=int(input())

s=n%10

if s%9==0:

print("YES")

else:

print("NO")
a=int(input())

b=int(input())

if a>b:

print(b)

else:

print(a)
n=int(input())

x=int(input())

if n%2!=0 or x%2!=0:

print("YES")

else:

print("NO")
a=int(input())

b=int(input())

if a%2!=0 and b%2!=0:

print("YES")

else:

print("NO")
a=int(input())

b=int(input())

if (a%2!=0 and b%2==0) or (a%2==0 and b%2!=0):

print("YES")

else:

print("NO")
n=int(input())

if n>0:

print(1)

elif n==0:

print(0)

else:

print(-1)
a=int(input())

b=int(input())

c=int(input())

if a<b<c:

print ("YES")

else:

print("NO")
a=int(input())

if (999>=a and a>=100)or(-999<=a and a<=-100):

print("YES")

else:

print("NO")
a=float(input())

b=float(input())

c=float(input())

if a<b<c:

print(float(a))

elif a>b<c:

print(float(b))

else:

print(float(c))
a=int(input())

b=int(input())

c=int(input())

if a==b==c:

print('3')

elif a==b!=c:

print('2')

elif a!=b==c:

print('2')

elif a==c!=b:

print('2')

else:
print('0')

bagana=int(input())

mor=int(input())

bagana2=int(input())

mor2=int(input())

if bagana==bagana2 and (mor2-mor<=7 or mor-mor2<=7):

print("YES")

elif mor==mor2 and (bagana-bagana2<=7 or bagana2-bagana<=7):

print("YES")

else:

print("NO")
a=int(input())

b=int(input())

if (a+b)%2==0:

print('BLACK')

else:

print('WHITE')
a=int(input())

b=int(input())

c=int(input())

d=int(input())

if (a+b)%2==0 and (c+d)%2==0:

print('YES')

elif (a+b)%2==1 and (c+d)%2==1:

print('YES')

else:

print('NO')
a=int(input())

b=int(input())

c=int(input())

if (b-a)>(c-a):

print(c-a)

else:

print(b-a)
a=int(input())

if str(a) [0]<str(a) [1]<str(a)[2]:

print('YES')

else:

print('NO')
a=int(input())

if str(a) [0]==str(a) [3] and str(a)[1]==str(a)[2]:

print('YES')

else:

print('NO')
a=int(input())

b=int(input())

c=int(input())

d=int(input())

if a-1<=c<=a+1 and b-1<=d<=b+1:

print('YES')

else:
print('NO')

a=int(input())

b=int(input())

c=int(input())

d=int(input())

if (a-c)**2==(b-d)**2:

print('YES')

else:

print('NO')
a=int(input())

b=int(input())

c=int(input())

d=int(input())

if (a-c)**2==(b-d)**2:

print('YES')

elif a==c and 0<b!=d<9:

print('YES')

elif b==d and 0<a!=c<9:

print('YES')

else:

print('NO')
a=int(input())

b=int(input())

c=int(input())

if a==b!=c:

print('3')

elif a!=b==c:

print('1')

else:

print('2')
a=int(input())

b=int(input())

c=int(input())

d=int(input())

if a-1==c and b-2==d:

print('YES')

elif a+2==c and b+1==d:

print('YES')

else:

print('NO')
a=int(input())

if a%4==0 and a%100!=0:

print('Өндөр жил')

elif a%400==0:

print('Өндөр жил')

else:

print('Хэвийн жил')
month = int(input())

day = int(input())

days_in_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

if 1 <= month <= 12 and 1 <= day <= days_in_month[month]:

next_day = day + 1

next_month = month

if next_day > days_in_month[month]:

next_day = 1

next_month = month + 1

print(next_month)

print(next_day)
a=int(input())

if a%2==0 and a!=2 and a!=12:

print("30 өдөр")

elif a==2:

print('28 өдөр')

elif a==8:

print('31 өдөр')

else:

print('31 өдөр')
x1=int(input())

y1=int(input())

x2=int(input())

y2=int(input())

x3=int(input())

y3=int(input())

if x1==x2 and y2!=y3:

x4=x3+x2-x1

y4=y3+y2-y1

print(x4)
print(y4)

elif x1==x3:

x4=x2+x3-x1

y4=y1+y2-y3

print(x4)

print(y4)

else:

x4=x3+x2-x1

y4=y3+y1-y3

print(x4)

print(y4)
a=int(input())

b=int(input())

c=int(input())

if a<b<c:

print(a,b,c)

elif b<a<c:

print(b,a,c)

elif a<c<b:

print(a,c,b)

elif c<a<b:
print(c,a,b)

elif b<c<a:

print(b,c,a)

else:

print(c,b,a)

col1=int(input())

row1=int(input())

col2=int(input())

row2=int(input())

if row1!=1 and (col1==col2 and row2==row1+1) or (col1 == col2 and row1 == 2 and row2 == 4) or
(abs(col2-col1)== 1 and row2== row1+1):

print("YES")
elif row1==1:

print("NO")

else:

print("NO")

a=float(input())
if 0<a<60:

print('F')

elif 59<a<70:

print('D')

elif 69<a<80:

print('C')

elif 79<a<90:

print('B')

elif 89<a<101:

print('A')

else:

print('Out of range')
Seminar 7 бодлого

n=int(input())

for i in range(1, n+1):

print(i)
x=int(input())

y=int(input())

for i in range(x,y+1):

print(i)
x=int(input())

for i in range(x+1):

s=i%2

if s!=0:

print(i)
a = int(input())

b = int(input())

if a<b:

for i in range(a,b+1):

print(i)

else:

for i in range(a,b-1,-1):

print(i)

a=int(input())

for i in reversed(range(a+1)):

if i%2==0:

print(i)
sum=0

for i in range(4):

sum=sum+int(input())

print(sum)
a = int(input())

sum=0

for i in range(a):

sum = sum+int(input())

print(a,"тооны нийлбэр:",sum)
a = input().split()

sum=0

for i in a:

sum=sum+int(i)

print("тооны нийлбэр:",sum)
sum=1

a=int(input())

for i in range(a):

sum=sum*int(input())

print(a,"тооны үржвэр:", sum)


n=int(input())

s=0

for i in range(1, n+1):

s+=i**3

print(s)
even=0

odd=0

a=input().split()

for i in a:

if int(i)%2==0:

even=even+1

else:

odd=odd+1

print("Жагсаалтад байгаа тэгш тоо:", even)

print("Жагсаалтад байгаа сондгой тоо:", odd)


n=int(input())

f=1

for i in range(2,n+1):

f*=i

print(f)
a=input().split()

sum=0

for i in a:

if int(i)%2==0:

sum=sum+int(i)

print("Жагсаалтад байгаа тэгш тооны нийлбэр:",sum)


n = int(input())

c=0

for i in range(n):

if int(input()) == 0:

c+=1

print(c)
n=int(input())

f=1

s=0

for i in range(n):

f=f*int(i+1)

s=s+f

print(s)
a = int(input())

b = int(input())

for i in range(a,b+1):

print(i,'*',i,'=',i*i,sep='')
n = int(input())

for i in range(1,n+1):

for j in range(1,i+1):

print(j,sep='',end='')

print()
n=int(input())

a = True

for i in range (2,int(n/2)+1):

if n%i == 0:

a = False

break

if a:

print('PRIME')

else:

print('COMPOSITE')
a = int(input())

b = int(input())

psk=True

for i in range (a,b+1):

psk=True

for j in range(2,int(i/2)+1):

if i%j==0:

psk=False

break

if psk:
print(i)

a = int(input())

b = int(input())

count = 0

for i in range(a,b+1):

psk=True

for j in range (2,int(i/2)+1):

if i % j == 0:

psk=False

break

if psk:

count += 1

print(count)
n=int(input())

sum1=0

el=0

elsum=0

if n !=1:

for i in range(1,n):

sum1 += i

el=int(input())

elsum += el
sum1 += i+1

print(sum1-elsum)

else:

print(1)
Seminar 8 Бодлого

a=int(input())

while a>0:

print(a)

a-=1
n=int(input())

i=0

s=0

while i<n+1 and s+4<n:

i+=1

s=i**2

print(s)
n=int(input())+1

s=0

while n>0:

n-=1

s=s+n

print("Тооны нийлбэр:",s)
n=int(input())

if n%2==0:

print(2)

elif n%3==0:

print(3)
n=int(input())

x=0

while 2**x<=n:

x+=1

print(x-1,2**(x-1))
x=int(input())

y=int(input())

i=1

while x<y:

x=x*1.1

i+=1

print(i)
i=0

while int(input())!=0:

i+=1

print(i)
i=0

n=int(input())

while n!=0:

i+=n

n=int(input())

print(i)
n=int(input())

sum=0

counter=0

while n!=0:

sum+=n

counter+=1

n=int(input())

print(sum/counter)
a = int(input())

m=a

while a != 0:

a = int(input())

if m < a and a != 0:

m=a

print(m)
prev = int(input())

answer = 0

while prev != 0:

next = int(input())

if next != 0 and prev < next:

answer += 1

prev = next

print(answer+1)
num_even = -1

element = -1

while element != 0:

element = int(input())

if element % 2 == 0:

num_even += 1

print(num_even)
list=input().split()

ctr=0

odds=0

while ctr<len(list):

if int(list[ctr])%2==1:

odds+=int(list[ctr])

ctr+=1

print("Жагсаалтад байгаа сондгой тооны нийлбэр:",odds)


list=input().split()

odd=0

even=0

i=0

while i < len(list):

n=int(list[i])

if n%2==0:

even+=1
else:

odd+=1

i+=1

print("Жагсаалтад байгаа тэгш тоо:",even)

print("Жагсаалтад байгаа сондгой тоо:",odd)

prev = int(input())

answer = 0

while prev !=0:

next = int(input())

if next !=0 and prev < next :

answer += 1

prev = next

print(answer)
first_max = int(input())

second_max = int(input())

if first_max < second_max:

first_max, second_max = second_max, first_max

element = int(input())

while element !=0:

if element > first_max:

second_max,first_max = first_max , element

elif element > second_max:

second_max = element
element = int(input())

print(second_max)

maximum=0

ctr=0

element=-1

while element!=0:

element=int(input())

if element>maximum:

maximum,ctr=element,1
elif element==maximum:

ctr+=1

print(ctr)

n = int(input())

if n == 0:

print(0)

else:

a, b = 0,1

for i in range (2,n+1):

a, b = b, a+b

print(b)
a = int(input())

if a == 0:

print(0)

else:

fib_prev, fib_next = 0,1

n=1

while fib_next<= a:

if fib_next == a:

print(n)

break
fib_prev,fib_next = fib_next, fib_prev + fib_next

n += 1

else:

print:(-1)

prev = -1

curr_rep_len = 0

max_rep_len = 0

element = int(input())

while element != 0:

if prev == element:

curr_rep_len += 1
else:

prev = element

max_rep_len = max(max_rep_len,curr_rep_len)

curr_rep_len = 1

element = int(input())

max_rep_len = max(max_rep_len,curr_rep_len)

print(max_rep_len)
Seminar 9-3 бодлого

import math

x1 = float(input())

x2 = float(input())

y1 = float(input())

y2 = float(input())

def distance(a1,a2,b1,b2):

sum = float(math.sqrt(math.pow(a2 - a1, 2) + math.pow(b2 - b1, 2)))

return sum
import math

a = float(input())

n = float(input())

def power(c,d):

return math.pow(c,d)
s = input()

x = s.split(" ")

sum = ""

for i in range(len(x)):

sum = sum + x[i].capitalize() + " "

print(sum)
a = float(input())

n = int(input())

def power(d1, i1):

def pwr(d,i,sm):

global smm

if i == 0:

smm = sm
return(sm)

else:

i=i-1

sm *= d

pwr(d,i,sm)

pwr(d1,i1,1)

return smm

x = []

def readlines():

inp = int(input())
x.insert(0,inp)

if inp != 0:

readlines()

readlines()

def reverse():

for i in range(len(x)):

print(x[i])

a = int(input())

def fib(a):

sm = 1

last = 0
for i in range(a - 1):

sm += last

last = sm - last

return sm
Seminar 10 Бодлого

n=input()

a=input()

s=(n.split(" "))

s.append(a)

print(s)
n=input()

a=input()

s=(n.split(" "))

b=(a.split(" "))

s.extend(b)

print(s)
n=input()

s=(n.split(" "))

print(list(reversed(s)))
n=input()

s=n.split(" ")

c=s.copy()

print("Хуучин жагсаалт",s)

print("Шинэ жагсаалт",c)
n=input().split(" ")

a=input()

i=int(a)-1

n.insert(i,a)

print(n)
a=input().split()

b=input()

a.remove(b)

print(a)
n=input().split()

b=int(input())

s=n.pop(b-1)

print(n)
n=input().split()

n.clear()

print(n)
n=input().split()

b=input()

s=n.index(b)

print(s+1)
n=input().split()

b=input()

x=n.count(b)

print(x)
n=input().split()

n.sort()

n.reverse()

print(n)
Явцын шалгалт 2
(16/20 onootoi)
Seminar 9-2 (file bolgoh code)
Building.py

#Python abs()

#Тооны модулыг олно

print(abs(-3))

#Python reversed()

#Өгөгдөлийг урвуугаар нь гаргана

list=(1,2,3,4,5)

print(reverse(list))

#Python min()

#Тухайн өгөгдөлийн хамгийн бага утгыг хэвлэнэ.

a=(1,2,3,4,5)

print(min(a))

#Python mаx()

#Тухайн өгөгдөлийн хамгийн бага утгыг хэвлэнэ.

a=(1,2,3,4,5)

print(max(a))

#Python pow()

#Зэрэгт дэвшүүлнэ

x=2

y=3

print(pow(x,y))

#Python round()
#Бутархай тоог тоймлоно

x = round(5.5)

print(x)

#Python eval()

#Python дотор Python-ийн үйлдэл гүйцэтгэнэ

x = 10

y=5

eval('z = x * y')

print(z)

#Python exec()

#Өгөгдсөн функцийг гүйцэтгэнэ

x = 10

y=5

code = """z = x + y

print(z)

"""

exec(code)

#Python len()

#Аливаа өгөгдөлийн урт, гишүүдийн тоог хэвлэнэ"

text = "Hello, World!"

length = len(text)

print(length) # Output: 13

#Python sorted()

#Өгөгдөлийг ангилан хэвлэнэ

numbers = [4, 1, 3, 7, 2]
sorted_numbers = sorted(numbers)

print(sorted_numbers)
Seminar 12-1 (file bogloh)

Bodlogo 1 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 1')

x=turtle.Turtle()

x.color('blue')

x.pensize(2)

x.shape('turtle')

x.speed(100)

for i in range(12):

x.penup()

x.forward(100)

x.pendown()

x.forward(20)

x.penup()

x.forward(20)

x.stamp()

x.backward(140)

x.right(30)
turtle.done()

turtle.bye()

Bodlogo 2 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 2')

x=turtle.Turtle()

x.color('pink')

x.pensize(4)

x.speed(100)

for i in range(1,6):

for i in range(1,5):

x.forward(20)

x.left(90)

x.pu()

x.forward(40)

x.pd()

turtle.done()

turtle.bye()

Bodloge 3 code:
import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 3')

arrow=turtle.Turtle()

arrow.color('pink')

arrow.pensize(3)

arrow.speed(100)

length=20

for i in range(5):

for i in range(1,5):

arrow.forward(length)

arrow.left(90)

arrow.penup()

arrow.backward(10)

arrow.right(90)

arrow.forward(10)

arrow.left(90)

arrow.pendown()

length+=20

turtle.done()

turtle.bye()
bodlogo 4 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 4')

def draw_poly(t,n,sz):

for i in range(n):

t.fd(sz)

t.left(360/n)

import turtle

t=turtle.Turtle()

t.color('pink')

t.pensize(3)

draw_poly(t,8,50)

turtle.done()

turtle.bye()

bodlogo 5 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 5')
arrow=turtle.Turtle()

arrow.color('blue')

arrow.pensize(4)

arrow.speed(100)

for i in range(5):

for i in range(4):

for i in range(4):

arrow.fd(100)

arrow.rt(90)

arrow.rt(90)

arrow.rt(18)

turtle.done()

turtle.bye()

bodlogo 6 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 6')

d=turtle.Turtle()

d.color('blue')

d.speed(100)

d.pensize(2)

d.penup()
d.backward(150)

d.pendown()

d.right(90)

x=3

for i in range(83):

d.fd(x)

d.rt(90)

x+=3

x=3

d.penup()

d.goto(0,0)

d.forward(150)

d.pendown()

d.right(90)

for i in range(83):

d.fd(x)

d.right(91)

x+=3

turtle.done()

turtle.bye()
bodlogo 7 code:

import turtle

sc=turtle.Screen()

sc.title('bodlogo 7')

t=turtle.Turtle()

def draw_equitriangle(t,sz):

for i in range(3):

t.fd(sz)

t.left(120)

draw_equitriangle(t,120)

turtle.done()

turtle.bye()

Bodlogo 8 code:

import turtle

sc=turtle.Screen()

sc.title('bodlogo 8')

x=turtle.Turtle()

x.speed(100)

for i in range(5):

x.fd(100)

x.rt(144)
turtle.done()

turtle.bye()

Bodlogo 9 code:

import turtle

sc=turtle.Screen()

sc.bgcolor("lightgreen")

sc.title('bodlogo 9')

x=turtle.Turtle()

x.color('pink')

x.speed(100)

x.pensize(4)

x.penup()

x.backward(200)

x.pendown()

for i in range(5):

x.penup()

x.fd(400)

x.pendown()

for i in range(5):

x.rt(144)

x.fd(100)

x.rt(144)
turtle.done()

turtle.bye()

Seminar 12-2 (file bolgoh)

from tkinter import *

window = Tk()

window.title("KM to Miles Converter")

window.geometry("300x40")

e1 = Entry(window, width=12)

e1.place(x=75,y=12)

var=StringVar()

la3 = Label(window,textvariable=var)

la3.place(x=160,y=12)

def btn1_click():

miles = round(float(e1.get())/1.609,2)

var.set(str(miles)+' miles')

bt1 = Button(window, text="Execute", command=btn1_click)

bt1.place(x=20,y=10)

window.mainloop()
Seminar 11 code (file bolgoh, gspread tatah, oyutni code, ner, groupin
dugaaraa bichih)
import gspread

from oauth2client.service_account import ServiceAccountCredentials

scope = ["https://www.googleapis.com/auth/spreadsheets",

"https://www.googleapis.com/auth/drive.file",

"https://www.googleapis.com/auth/drive"]

creds = ServiceAccountCredentials.from_json_keyfile_name("APF221.json",scope)

client = gspread.authorize(creds)

sheet = client.open('APF221Seminar11').sheet1

sheet.insert_row(["OYUTNII CODE OO BICH","NEREE BICH","GROUPIIN DUGAARAA BICH"],2)

#result = sheet.get_all_records()

row = sheet.row_values(2)

print(row)

You might also like