#AsuultSambar :

ASUULT.NET - МОНГОЛ УЛС МАНДАН БАДРАГ!
It is currently Oct.17.18 3:45 am

All times are UTC+09:00




Post new topic  Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Jul.28.13 4:53 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Python ni hediigeer zaluu bolowch ihenh 3d-iin script language bolj chadsan baina. Jishee ni panda3d game engine, blender, Maya... . Ingeed python heliig suratsgaaya

hello world jishee:
Code:
#dan hashilttai
print 'hello world'
#dawhar hashilttai
print "hello world"
#dan hashilt bolon haalt
print('hello world')
#dawhar hashilt bolon haalt
print("hello world")



Quote:
output:
hello world
hello world
hello world
hello world


dan bolon dawhar haaltiin heregleeg tsaashdiin hicheeld yarigdah bolno.


Top
   
PostPosted: Jul.28.13 5:04 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Code:
print "Welcome\nto\n\nPython!"

neg mor programiin ur dun ni 4 mor boloh bolno
Quote:
Welcome
to

Python!


\n shine mor awah
\t delgetsen deer baigaa cursoriig daraagiin 'tab' bairlald awiachih
\r cursoriig hamgiin anhnii bairlald awiachina (ene ni zowhon hewtee tenhelgiin huwid)
\b backspace
\\ '\' -ig hewlene
\' dan hashiltiig hewlene
\" dawhar hashiltiig hewlene

ene bugd tsaashiin jisheend ih olon oroh baih.


Top
   
PostPosted: Jul.28.13 5:30 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Code:
neg_dugeer_too = raw_input( "neg_dugeer_too -g oruulna uu" ) # ene morond garaas utga oruulna
neg_dugeer_too = int( neg_dugeer_too ) #ene morond string utgiig int utga bolgon huwirgana
hoyor_dugaar_too = raw_input( "hoyor_dugaar_too -g oruulna uu" ) # ene morond garaas utga oruulna
hoyor_dugaar_too = int(hoyor_dugaar_too)

print(neg_dugeer_too + hoyor_dugaar_too)


Quote:
neg_dugeer_too -g oruulna uu
1
hoyor_dugaar_too -g oruulna uu
1
2


neg_dugeer_too, hoyor_dugaar_too 2laa l object, harin object bolgond <type><size>[value]<location> baidag.
object1 = "2" ene morond type = String bolj object1 shineer zarlagdana
object1 =int(object1) #ene morond type = Integer bolj object1 shineer zarlagdana
uuniig batalgaa bolgon daraah code-iig bichij uzetsgeeye

Code:
object1 = "2"
print(id(object1), type(object1))
object1 =int(object1)
print(id(object1), type(object1))


ene ur dund tanii mashin deer oor garah ni oilgomjtoi
Quote:
(30797768, <type 'str'>)
(30649588, <type 'int'>)


Top
   
PostPosted: Jul.28.13 6:07 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Arithmetic operatoriin huwid daraah baidlaar:

|ner | temdeg | jishee | python bichilt |
__________________________________________
|nemeh | + | 1 + 2 | 1 + 1 |
|hasah | - | 1 - 2 | 1 - 1 |
|urjih | * | 1 * 2 | 1 * 2 |
|zereg | ** | x^y | x**y |
|huwaah | / | x/y | x/y |
|huwaah | // | x÷y | x//y | noogdwor ni tegsh too!!
|uldegdel | % | x mod y | x%y |

odoo ene buh uildeliig jisheegeer uziye

Code:
print "nemeh 10 + 2 = \t\t", 10 + 2 
print "hasah 4 - 6 = \t\t", 10 + 2
print "urhij 9 * 1.1 = \t", 9*1.1
print "zereg 2-n 5 zereg ni \t", 2**5
# daraagiin mornii uildel tiimch saihan sanaa bish gedgiig sain sanaarai!!!
print "huwaah 12/5 = \t\t", 2/5
#huwaahad anhaarah zuil: hamgiin bagadaa huwaagch huwaagdagch 2 iin ali negiig ni float helbereer bichih
print "huwaah 12/5 = \t\t", 2/5.0
#   noogdwor ni tegsh too!!
print "huwaah 12//5 = \t\t", 12.0//5.0
print "huwaah 12//5 = \t\t", 12//5.0
print "uldegdel 12%5 = \t", 12%5


"print object1,object2, ...,objectn" neg mor print olon object heleh bolomjtoi


Quote:
nemeh 10 + 2 = 12
hasah 4 - 6 = 12
urhij 9 * 1.1 = 9.9
zereg 2-n 5 zereg ni 32
huwaah 12/5 = 0
huwaah 12/5 = 0.4
huwaah 12//5 = 2.0


Top
   
PostPosted: Jul.28.13 6:33 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
odoo bidend neg iim asuudal garj irj boloh yum, tanii uureg bol neg morond iim yum hewleh
"12-iin 5 zereg ni 248832 ene too ni 2-iin 10 zeregiig urjih ni 243-tai tentsuu yum"
uuniig bidnii medej baigaa argaar olon object hewlej bolno,

Code:
print 12,"-iin", 5,"zereg ni ", 12**5,"ene too ni", 2,"-iin", 10,"zeregiig urjih ni", 243,"-tai tentsuu yum"


iimerhuu olon daraalaltai zuiliig udirdan tiim ch saihan bish. harin uuniig ingej oorchilj bolno

Code:
print "%d-iin %d zereg ni %d ene too ni %d-iin %d zeregiig urjih ni %d -tai tentsuu yum"%(x,y,x**y,a,b,x**y/a**b);


string iin dund oruuldag uuniig string formatting gej nereldeg ba uund "%d" gesen temdegt ni ni integer -iig orluulan bairluuldag. ingeed busad utgiig ni hariya

c ~ single character
s ~ string
d ~ signed decimal integer
u ~ unsigned decimal integer
o ~ unsigned octal integer
x ~ unsigned hexadecimal integer ( hex ni jijig usgeer)
X ~ unsigned hexadecimal integer ( hex ni tom usgeer)
f ~ floating-point number
e ~ floating-point number (e too hereglen ilerhiilegdeh)
g ~ floating-point number (%ABg, AB iingiin orongiin nariiwchlaltai)


Top
   
PostPosted: Jul.28.13 7:04 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Haritsuulah operator (equality operator)

> —— x > y —— x ni y -ees ih
< —— x < y —— x ni y-ees baga
≥ —— x >= y —— x ni y-ees ih buyu tentsuu
≤ —— x <= y —— x ni y-ees baga buyu tentsuu
= —— x == y —— x ni y-tei tentsuu
≠ —— x != y —— x ni y-tei tentsuu bish
≠ —— x <> y —— x ni y-tei tentsuu bish

Code:
x = 12
y = 13
print"%d ni %d-ees ih :"%(x,y),x>y
print"%d ni %d-ees baga :"%(x,y),x<y

y = 12
print"\n%d ni %d-ees ih buyu tentsuu :"%(x,y),x>=y
print"%d ni %d-ees baga buyu tentsuu :"%(x,y),x<=y

x = 12.1
y=12.2
print"\n%.1f ni %.1f-ees ih buyu tentsuu :"%(x,y),x>=y
print"%.4f ni %.4f-ees baga buyu tentsuu :"%(x,y),x<=y

print "\n%.1f ni %.1f-tei tentsuu :"%(x,y),x==y
print "%.4f ni %.4f--tei tentsuu bish :"%(x,y),x<>y

#zarimdaa hereglegch tal deer iim yum boldog
print "\n%d ni %d-tei tentsuu :"%(x,y),x==y
#hereglegch code harahgui zowhon ur dun harna, yagaad adilhan 2 toog, 2 oor gej dugnelt hiiw gej
#zaza ene bi zugeer l iluu ugelchihlee


Quote:
12 ni 13-ees ih : False
12 ni 13-ees baga : True

12 ni 12-ees ih buyu tentsuu : True
12 ni 12-ees baga buyu tentsuu : True

12.1 ni 12.2-ees ih buyu tentsuu : False
12.1000 ni 12.2000-ees baga buyu tentsuu : True

12.1 ni 12.2-tei tentsuu : False
12.1000 ni 12.2000--tei tentsuu bish : True

12 ni 12-tei tentsuu : False


Top
   
PostPosted: Jul.28.13 7:50 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
odoo logic operatortoi bolson tul
if statementeer togliyo

Code:
print 'ta oorii hereglegchiin neriig oruulna uu'
print 'tanii hereglegchiin ner "user" baiwal zugeer baina'

name = raw_input(":")

if name=='user':
    print('sain baina uu "user" hereglegch')
else:
    print('ooriig chini tanihgui yum baina')

user - gej garaas oruulsan baina
Quote:
ta oorii hereglegchiin neriig oruulna uu
tanii hereglegchiin ner "user" baiwal zugeer baina
:use
ooriig chini tanihgui yum baina


if statementiig zagwar daraah baidlaar
Quote:
if <notsol> :
[nohtsol zow bol]
[else:]
[nohtsol buruu bol]


Top
   
PostPosted: Jul.28.13 8:10 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
ehenh programming jishee ni deer baidag grade shalgadag code-iig python deer bichij hariya

Code:
grade = int(raw_input(":"))
if grade>=90: print 'A'
if grade>=80: print 'B'
if grade>=70: print 'C'
if grade>=60: print 'D'
if grade>= 0: print 'F'


herew unelgee 90 bailaa gej tootshod
grade>= 90 nohtsol zow ingeed A -iig hewlene, daraagiin alhamd
grade>=80 iig shalgan, bas l zow 90, 80-aas ih B
ene suragch 90 onoo awsaniihaa toloo A,B,C,D,F awaad, herwee ulamjlalt argaad dundjilawl C garna
omno uzseneeree bol else geed bichiye

Code:
grade = int(raw_input(":"))
if grade>=90:
     print 'A'
else :
    if grade>=80 :
         print 'B'
    else:
        if grade>=70:
            print 'C'
        else:
            if grade>=60:
                print 'D'
            else:
                print 'F'


ur dun ni zow garj baina uu?
odoo gants oyuutan bish olon oyuutan bailaa gej tootsiyo bas garaas olon udaa too oruulmaargui baigaa tul uuniig random utgaar oruulah geed oroldoyo, uunii tuld yaagaad c, c++,c#, java, python....geh met heluudiig iheer heregleh bolson hamgiin engiin shaltgaan boloh nemelt library-g ashiglah heregtei bolno. undsen function bish nemelteer hunii bichsen belen code ashiglah bolomjiig neej ogdog. ugui bol assembly language -shig technique sudlaad teriigee bichih bolno.

Code:
import random
num = random.randint(1,20)
grade = 5*num
print grade
if grade>=90:
     print 'A'
else :
    if grade>=80 :
         print 'B'
    else:
        if grade>=70:
            print 'C'
        else:
            if grade>=60:
                print 'D'
            else:
                print 'F'


import random —— oor class buyu angi "random" iig nemen oruulj baina
num = random.randint(a,b) —— num object zarlah, random iin randint function a, b ogoh utgiin hamt duudah (a<= num<=b)
a-aas b- hurtel hureend duriin utga butsaaj ogno. funct-iin huwid daraa bid ooriin funts class uusgeh uyd iluu todorhoi bolno

olon oyuutanii neg asuudal random-aar shiidegdlee, odoo harin 30 suragchiin dung zohiomloor turshih geheer programmaa 30 udaa ajiluulj oruulna, ali eswel zowhon heregtseetei statement-ee program dotor 30 udaa unshuulah
bid ehleed while()-aar awj uziye

while <nohtsol> :
statement

Code:
import random
count = 0
while count <30:
    count = count +1
    num = random.randint(1,20)
    grade = 5*num
    print grade
    if grade>=90:
        print 'A'
    else :
        if grade>=80 :
            print 'B'
        else:
            if grade>=70:
                print 'C'
            else:
                if grade>=60:
                    print 'D'
                else:
                    print 'F'


ur dun neleen zambraagui utaggui yum garj irlee, uniig daraah baidlaar jaahan tsegtsleed uziye
Code:
import random
import array
student_onoo = array.array('I', [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
student_dun = array.array('c', 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')
count = 0
while count <30:
    count = count +1
    num = random.randint(1,20)
    grade = 5*num
    value = 'F'
    if grade>=90:
        value = 'A'
    else :
        if grade>=80 :
            value= 'B'
        else:
            if grade>=70:
                value = 'C'
            else:
                if grade>=60:
                    value = 'D'
    student_onoo[count-1] = grade
    student_dun[count-1] = value   
    print "oyuutan %d-iin unelgee = %d, dun = %s"%(count,grade,value)


massive, array:
pythond bol array gej nereldeg yumsanj, array class-iin array functs. zarlah boloh heregleh ni daraah baidlaar :


import array
object = array.array('<x_char>','value_1, value_2, value_3,....., value_n')

x_char ni daraah baidlaar :

'c' character
'b' signed char int
'B' unsigned char
'u' Py_UNICODE
'h' signed short
'H' unsigned short
'i' signed int
'I' unsigned int
'l' signed long int
'L' unsigned long
'f' float
'd' double

manai jishend 'c' butuu character bolon 'I' buyuu unsigned int herglesen baigaag anzaarsan bizdee.

array-t utga onooh :
array_objectiin_ner[array_objectiiin_daraalal] = onooh_utga
manai jishee:
student_onoo[0] = 50
student_dun[0] = 'F'
array-s utga awah :
hewleh jisheen deer uziye
print array_objectiin_ner[array_objectiiin_daraalal]
manai jishee :
print student_onoo[]


Top
   
PostPosted: Jul.29.13 12:42 am 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
while -aar 0 - oos 10 hurtel
Code:
counter = 0
while counter <= 10:
    print counter
    counter += 1


for -oor 0 -oos 10 hurtel

Code:
for counter in range( 10 ):
    print counter


omno bichsen 30 suragchtai jisheeg for statementeer solij bichij uzeerei.

java-aar for-iig bichhed zarimdaa jaahan tolgoi eregchihgeed baidag for python deer mash hyalbar zagwar ni daraah baidlaar:

for <huwisagch> in range(a,b,c):
<loop statement>

uund baigaa a ni ehleh too, b ni duusah too, c ni alham.

0 - 10 jisheen deer haragdaj baigaa range(10) gedeg ni defualt utgiig orhison /hemnesen/
uuniig delgeruulj bichhed :
for counter in range(0,10,1) —— 0 oos ehleed 10 hurtel 1-eer nemegdene.

Urwuu daraalal bichij bas bolhiig bid turshiltaar uziye:

Code:
for counter in range(10, 0, -1 ):
    print counter


range(a,b,c) ni ooroo functs bogood uniig for-guigeer shuud hereglej bas bolni daraag baidlaar :

Code:
range(10, 0, -1 )


butsaah utga ni array tul array baidlaar utgaa songoj hereglej bas bolno

Code:
range(10, 0, -1 )[0]


Manai muu awdag oyuutnuudiig, pythonii random deerelheed baigaa eshiig bid bas shalgah heregtei, ingesneerei bid iluu surah bolomjtoi yum
Code:
import random
import array
stas = array.array('i',[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
for x in range(0,10000,1):
    grade = random.randint(1,20)
    stas[grade-1]= stas[grade-1] +1;

print stas


Quote:
array('i', [499, 504, 514, 508, 509, 490, 510, 520, 502, 487, 529, 465, 491, 513, 496, 481, 490, 487, 536, 469])

miniih iim baidlaar garj irj baina hamgiin ih ni neg too 536 udaa tohioldoj hamgiin baga ni 465 udaa tohioldoj, zoruu ni 76 udaa tohioldoj. 0.76 % iin shudraga bish baina, ene too bol random toonii huwid heterhii tegsh handsan baina.
ene uildeliig hiihed array zarlana hereglene gedeg hamgiin uitgartai ajil bailaa.

x*0 for x in range(0,20,1) iim code-oor baahan noil gesen utgaa zarlaj bolno

Code:
import random
import array
stas = array.array('i',[ x*0 for x in range(0,20,1) ])
dund = 0
for x in range(0,10000,1):
    grade = random.randint(1,20)
    stas[grade-1]= stas[grade-1] +1;
print stas


deerh code jaahan hetsuu sanagdah uyd, deed tuwshingiin programuudad baidag container heregtseegee gargana
yalgaa gewel angilan sawlah bolomjgui bolno, integer, string, char, float bugd neg dor. uulna array-iig hereglej yawbal tom zuil deer hugatsaanii huwid iluu ur duntei baidag bolowch, sort-loh gehees ehleed numpy heregleh boldog uchir bid ehleed listeer heseg yawiya
listiig zaralhad yuuch zaagaad hereggui mash hyalbar jishee:

Code:
import random

stas = [ x*0 for x in range(0,20,1) ]
dund = 0
for x in range(0,10000,1):
    grade = random.randint(1,20)
    stas[grade-1]= stas[grade-1] +1;
print "angilaagui",stas
stas.sort()
print "osoh baidlaar angilsan",stas
stas.reverse()
print "buurah baidlaar angilsan",stas


ingeed minii delgetsen deer garj baigaa ur dun bol :
Quote:
angilaagui [477, 487, 501, 532, 505, 516, 494, 473, 541, 466, 565, 530, 483, 492, 522, 506, 450, 444, 491, 525]
osoh baidlaar angilsan [444, 450, 466, 473, 477, 483, 487, 491, 492, 494, 501, 505, 506, 516, 522, 525, 530, 532, 541, 565]
buurah baidlaar angilsan [565, 541, 532, 530, 525, 522, 516, 506, 505, 501, 494, 492, 491, 487, 483, 477, 473, 466, 450, 444]



30 suragchiig dugaartai, duntei, onootoi, ni daraalalsan baidaltaigaar uzuuliye gewel:

Code:
import random

a = []

for x in range(0,30,1):
    grade = random.randint(1,20)*5
    value = 'F'
    if grade>=90:
        value = 'A'
    else :
        if grade>=80 :
            value= 'B'
        else:
            if grade>=70:
                value = 'C'
            else:
                if grade>=60:
                    value = 'D'
    a.append([x,grade,value])

for x in range(len(a)):
    print "%d-r oyuutnii dun %d, unelgee %s"%(x+1,a[x][1],a[x][2])


Quote:
1-r oyuutnii dun 75, unelgee C
2-r oyuutnii dun 20, unelgee F
3-r oyuutnii dun 70, unelgee C
4-r oyuutnii dun 95, unelgee A
5-r oyuutnii dun 50, unelgee F
6-r oyuutnii dun 35, unelgee F
7-r oyuutnii dun 15, unelgee F
8-r oyuutnii dun 90, unelgee A
9-r oyuutnii dun 65, unelgee D
10-r oyuutnii dun 25, unelgee F
11-r oyuutnii dun 80, unelgee B
12-r oyuutnii dun 80, unelgee B
13-r oyuutnii dun 60, unelgee D
14-r oyuutnii dun 95, unelgee A
15-r oyuutnii dun 95, unelgee A
16-r oyuutnii dun 60, unelgee D
17-r oyuutnii dun 5, unelgee F
18-r oyuutnii dun 55, unelgee F
19-r oyuutnii dun 75, unelgee C
20-r oyuutnii dun 90, unelgee A
21-r oyuutnii dun 35, unelgee F
22-r oyuutnii dun 10, unelgee F
23-r oyuutnii dun 40, unelgee F
24-r oyuutnii dun 60, unelgee D
25-r oyuutnii dun 100, unelgee A
26-r oyuutnii dun 60, unelgee D
27-r oyuutnii dun 10, unelgee F
28-r oyuutnii dun 70, unelgee C
29-r oyuutnii dun 35, unelgee F
30-r oyuutnii dun 65, unelgee D


Top
   
PostPosted: Jul.30.13 1:57 am 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
suuliin hicheel deer 2 hemjeest list awsan baina. 1 hemjeestees yalgaa ni gewel element ni ooroo list.
tuuniig elementiig duudahdaa daraah baidlaar

list[1] ~ 2-r element
list[1][0] ~ -2-r elementiin 1-r element

Code:
a = [1,1,2,1]
print a[0]
print a

Quote:
1
[1, 1, 2, 1]

deerh heseg code, ur dun 2-iig ni harwal endees bid heden dugnelt hiij bolno.
1. listiin element dawtagdaj bolno
2. list ni automataar bish sort() functs-iig duudaj daraalald ordog
3. element bur ooriin daraalald baigaa dugaartai

list-iig uildeld oruulah ni:
list1 + list2 = list1,2

print ["hohoo shuwuu"] + ["dongodson"]
outline: ['hohoo shuwuu', 'dongodson']

tegwel hasaj boloh bolow uu?

print ["hohoo shuwuu"] + ["dongodson"] -["dongodson"]
outline : TypeError: unsupported operand type(s) for -: 'list' and 'list' ~ geh meteer aldaa zaasan zurwas oort chini elgeene

print ["hohoo shuwuu"]*2
outline: ['hohoo shuwuu', 'hohoo shuwuu']

b = 12
l=['1','shuwuu',2,'3', b]
print l
outline :['1', 'shuwuu', 2, '3', 12]

*oor neg huwisagchiig dotor ni aguulj bolj baina gesen ug*

b = 12
l=['1','shuwuu',2,'3', b]
print l[2:] # 2-r gishuunees hoishd
outline :[2, '3', 12]

b = 12
l=['1','shuwuu',2,'3', b]
print l[:2] # 2-r gishuunees uragsh
outline : ['1', 'shuwuu']

b = 12
l=['1','shuwuu',2,'3', b]
print l[-2] # togsogloos 2-r gishuun
outline : 3

b = 12
l=['1','shuwuu',2,'3', b]
print l[-2:] # togsgoliin 2-r gishuunees hoish
outline:['3', 12]

b = 12
l=['1','shuwuu',2,'3', b]
print l[:-2] # togsgoliin 2-r gishuunees uragsh
outline:['1', 'shuwuu', 2]

b = 12
l=['1','shuwuu',2,'3', b]
print b in l # b huwisagch l -d baigaa yuu
outline: True

b = 12
l=['1','shuwuu',2,'3', b]
l2 = ['1','shuwuu']
print l2 in l # l2 list l-d baigaa yuu
outline: false

b = 12
l=['1','shuwuu',2,'3', b]
l2 = ['1','shuwuu']
print l2[0] in l and l2[1] in l #l2-iin 1-r gishuun bolon l2-iin 2-r gishuun l-d baigaa yuu
outline: True


s= 0
for i in [0,1,2,3,4,5,6,7,8,9]:
s += i
print "total",s
outline : total 45

for-iin ard bichdeg range-iin orond list, array ... geh metiig bichij boloh yum baina.

list1 = [0,1,2,3,4,5,6,7,8,9]
print "total",sum(list1)
outline : total 45

deerh jishee omnoh jishee-gee hyalbar bolgson

list1 = [0,1,2,3,4,5,6,7,8,9]
del list1[0],list1[2],list1[3]
print list1
outline : [1, 2, 4, 6, 7, 8, 9]

list-iin gishuunii bairlalaar ni ustgaj bolson jisheeg deer harj baina

list1 = [0,1,2,3,4,5,6,7,8,9]
print max(list1)
outline: 9

hamgiin ihiig ni

list1 = [0,1,2,3,4,5,6,7,8,9]
print max(list1)
outline: 0

hamgiin baga

list1 = [0,1,2,3,4,5,6,7,8,9,False]
print any(list1)
outline: True

listend ali neg ni True utga aguulsan uyd True, herew bugd False baiwal False

list1 = [0,1,2,3,4,5,6,7,8,9,False]
print all(list1)
outline: False

listend bugd True baiwal True, ali neg ni False baiwal False

list1 = [0,1,2,3,4,5,6,7,8,9]
print len(list1)
outline: 10

listiing urtiig haruulj

list1 = [0,1,10,44,97958,12333,6,0,99,9]
list1.sort() #osoh daraalal
print list1
list1.reverse() #buurah daraalal
print list1
outline:
[0, 0, 1, 6, 9, 10, 44, 99, 12333, 97958]
[97958, 12333, 99, 44, 10, 9, 6, 1, 0, 0]

listiig daraaluulsan baina


list1 = [0,1,2,3,4,5,6,7,8,9,False]
list1.append(False)
print list1
outline: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, False, False]

list-iin togsgold element nemeh

list1 = [0,1,2,3,4,5,6,7,8,9,False]
list2 = [True,'Turu']
list1.extend(list2)
print list1
outline: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, False, True, 'Turu']

list1-iig list2 -oor orgotgoh. gehdee ene ni shuud list2 = list2 + list1 gedgees oor, Iterator-iig hereglen oruuldag baina
/iterator bolor toli deer tooluur gej orchuulsan, minii ooriin oilgoltoor bol toloolon orluulagch (java, c++, c# --in adil)/

list1 = [0,1,2,3,4,5,6,7,8,9,False]
list1.insert(3, '4-r element')
print list1
outline: [0, 1, 2, '4-r element', 3, 4, 5, 6, 7, 8, 9, False]

listend shurguulah uildel

list1 = [0,1,2,3,4,5,6,7,8,9,False]
a= list1.pop()
print "listnees awsan defualt ugaar ni awsan", a
print "defualt ugaar ni awsanii daraa listend uldsen", list1
a= list1.pop(-len(list1))
print "list-nii urtiig oruulan hamgiin ehnii elmentiig awsan", a
print "list-nii urtiig oruulan hamgiin ehnii elmentiig awsanii daraa listend uldsen", list1
outline:
listnees awsan defualt ugaar ni awsan False
defualt ugaar ni awsanii daraa listend uldsen [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
list-nii urtiig oruulan hamgiin ehnii elmentiig awsan 0
list-nii urtiig oruulan hamgiin ehnii elmentiig awsanii daraa listend uldsen [1, 2, 3, 4, 5, 6, 7, 8, 9]

list1 = [0,1,2,3,4,5,6,7,8,9,0,0,False]
list1.remove(0)
list1.remove(0)
print list1
outline: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, False]

list-nees 0 elementiig 2 udaa arilagasan baina. ene remove functs ni hamgiin ehnees 1 udaa guitsetgej baigaag ajiglaarai.

list1 = [0,1,2,3,4,5,6,7,8,9,0,0,False,'0']
print list1.count(0)
outline: 4

listend heden element ni 0 baigaag haruulj, anhaarah ni '0' -bol integer bish

list1 = [0,1,2,3,4,5,6,7,8,9,0,0,False,'0']
print "2-r elementees hoishih 0 elementiin index bol: ", list1.index(0,1)
print "defual utgaaraa buyu hamgiin ehnii 0 elementiin index bol:", list1.index(0)
outline:
2-r elementees hoishih 0 elementiin index bol: 10
defual utgaaraa buyu hamgiin ehnii 0 elementiin index bol: 0

deerh jisheend tailbar iluuts biz


Top
   
PostPosted: Jul.30.13 2:32 am 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
neg hyalbar togloom met yum bichiye
shagai hayadag, garaas : 1 gej oruulhad togloom zogsono, busad temdegt shagaig hayana . hayahaar shoond yuu taarsaniig delgetsend haruuliya

Code:
import random

while True:
    roll_shagai = {1:'honi',2:'yamaa',3:'mori', 4: 'temee'}
    oruulga = raw_input("shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu\n")
    if oruulga == '1':
        break
    else :
        shagai = random.randint(1,4)
        print "shagai %s buusan baina\n"%roll_shagai[shagai]


Quote:
shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu
2
shagai honi buusan baina
shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu
2
shagai honi buusan baina
shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu
1

2 udaa honi buulaa. za gol sedew maani dictionary

roll_shagai = {1:'honi',2:'yamaa',3:'mori', 4: 'temee'} # ene bol dictionary, tuuniig urd baigaa elementeer ni hargalzah elementiig ni duudaj baigaag deerh jisheend uzuulsen baina
roll_shagai[shagai]

herwee ene toli bichig geden nertei object yum bol urd baigaa element ni yuuch baisan boloh tal deer daraah jisheeg uziye

Code:
import random

while True:
    roll_shagai = {1:'honi',2:'yamaa',3:'mori', 4: 'temee'}
    shaigand_taarsan_buutsiin_tol_mal = {'honi':'hurga','yamaa':'ishig','mori':'unaga','temee':'botogo'}
    oruulga = raw_input("shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu\n")
    if oruulga == '1':
        break
    else :
        shagai = random.randint(1,4)
        print "shagai %s buusan baina\n"%roll_shagai[shagai]
        print "shagaind buusan maliin tol ni :",shaigand_taarsan_buutsiin_tol_mal[roll_shagai[shagai]]

Quote:
shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu
2
shagai mori buusan baina

shagaind buusan maliin tol ni : unaga
shagai hayah bol yamar negen temdegt oruul, garah bol 1 -iig oruulna uu


boldog boloh ni todorhoi bolow, tegwel neg sonin jishee uziye:
Code:
a= 1
b= 2
c = 3
dict1 = {a:1,b:2,c:3}
a=2
print dict1[a]

hariu ni yuu gej garah tuhai yariltsaya. herwee a gishuund 1 onoogdoj baigaa bol hariu ni 1, herwee a gishuunii utgaar ni 2 haritsah ni 2 gedgeer ni hadgalj baigaa bol 2 gesen hariu ogoh heregtei.

dict -iin zagwar bol ih todorhoi
name={key:value}

ajilaa hiih tul 2 honog yum oruulahgui baij magad.


Top
   
PostPosted: Aug.01.13 12:29 am 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Code:
dic1 = {1:2,2:1,3:1,3:2}
print dic1[1]
print dic1[2]

deerh code-noos neg dugnelt hiiye *listtei haritsuulsan baidlaar

list bol elementuudiig erembe daraalalgui, nohtsolguigeer hadgalahdaa element bolgond jagsaaliin dugaar gej baina
harin dict-bol uunees yalgaatai neg l zuil bi ene ni jagsaaliin too bish harin key ni aguulgiig duudah yum baina.
harin shine gishuun nemeh tal deer ene 2-iig haritsuulhad:

Code:
import time
list=[]
millis1 = int(round(time.time() * 1000))
for x in range(0,10000000,1):
    list.append(x)
millis2 = int(round(time.time() * 1000))
print millis2- millis1

Quote:
2162


Code:
import time
dic={}
millis1 = int(round(time.time() * 1000))
for x in range(0,10000000,1):
    dic[x] = x
millis2 = int(round(time.time() * 1000))
print millis2- millis1

Quote:
2159


harin elementiig tus burd ni heregleh tal deer bol:

Code:
import time
list=[]
for x in range(0,10000000,1):
    list.append(x)
millis1 = int(round(time.time() * 1000))
for x in list:
    a = x
millis2 = int(round(time.time() * 1000))
print millis2- millis1

Quote:
1093


Code:
import time
dic={}
for x in range(0,10000000,1):
    dic[x] = x
millis1 = int(round(time.time() * 1000))
for x in dic:
    a = dic[x]
millis2 = int(round(time.time() * 1000))
print millis2- millis1

Quote:
1614


heregleenii huwid list ni 2/3 hugatsaanii hemnelttei, tom hemjeenii database, renderiin program bichih gej baigaa bol dictionory udaan bolowch saihan songolt, list bol hurdan bas l saihan songolt bolj taarah yum baina

time -iin huwid:
a = time.time()
time - class -iin time() functs
a -d onooh ni tuhain system iin second -iig 11 orongiin nariiwchlaltai uzuulne

round() functs :
print round(1.59599995613)
outline : 2.0

print round(1.49599995613)
outline : 1.0

oorosdoo oilgochooroi plz

harin odoo yamar neg t*n*g zuiliig python bolon java deer bichin haritsuulj uziye. uildluudees hamgiin udaan hiigdeh ni oilgomjtoi huwaah uildel.
java:
Code:
public class Main {
   public static void main(String args[]){
      Long l1 =System.currentTimeMillis();
      for(int i = 0; i<=1000000;i++){
         double a= 3.0/5.0;
      }
      Long l2 =System.currentTimeMillis();
      System.out.println(l2 - l1);
   }
}


outline : 1

Code:
import time
millis1 = int(round(time.time()*1000))
for i in range(1000000):
    a = 3.0/5.0
millis2 = int(round(time.time()*1000))
print millis2 - millis1


outline : 153

WTF is this. yamarch arga baihgui, ene zolig mash ih yumnii script tiim bolhoor idewhtei tsaash ni suraad bai. tom program bichihgui l bol uugeer sanhuugiin programch bichsen ch bolno. bas ene User Interface-dee mash muu.
hehe. za ingeed daraachiin 7 honog tahin neg yum bichiye.


Top
   
PostPosted: Aug.01.13 12:32 am 
Offline
Асуулт Самбарын Хvндэт Харуул
User avatar

Joined: Aug.15.07 11:21 am
Posts: 6491
sonirholtoi l um.

_________________
www.hicheel.com


Top
   
PostPosted: Aug.12.13 5:07 am 
Offline
Шинэков Гишvvн
Шинэков Гишvvн

Joined: Aug.12.13 4:50 am
Posts: 2
сонирхолтой хичээл байна. цааш нь үргэлжлүүлээд байгаарай.
аа тийн бас дээрээс нь криллээр бичсэн бол илүү гоё болох байжээ. за амжилт!


Top
   
PostPosted: Sep.20.13 12:05 pm 
Offline
Төгөлдөр гишvvн
Төгөлдөр гишvvн

Joined: Feb.26.13 12:21 am
Posts: 82
Ih udaan hugatsaand zawgui baisan bolhoor yum oruulj chadaagui toirsoor hicheeliihee hotolboriigch martaj,
Za nurshuu yaria, saihan zurag, kino geh meteer hunii uhaanii hogjoliig udaashruuldag zuilseer yaahaw.
Nadad arai hurdatstai surah neg sanaa torloo ene bol togloom bichih.

heregtei zuils photoshop, pygame (install ni interneted baigaa), and medeej python, notepad


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 15 posts ] 

All times are UTC+09:00


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Copyright Asuult.NET © 2000-2015.
Administrative Contact: Khundaga Khurelbaatar [hundaga@hotmail.com]
Tel: 1-888-303-4927, Fax: 1-888-406-2264.
Powered by phpBB © 2000-2015 phpBB Group. Powered by phpBB® Forum Software © phpBB Limited