#String metodlari ism='umidbek'


Download 112.32 Kb.
Sana18.12.2022
Hajmi112.32 Kb.
#1031376
Bog'liq
Gitxob Python O\'zim uchun


#print(c)
#String metodlari
ism='umidbek'
sharif='madraimov'
ism_sharif=f"{ism} {sharif}"
print(ism_sharif.upper()) #upper- hamma harifni kattaga aylantiradi(UMIDBEK MADRAIMOV)
ism_sharif=ism_sharif.upper() # qiymatni kattaa hariflar bn qabul qiladi
print(ism_sharif.lower()) # matindagi barcha harifni kichik hariflarga aylantiradi(umidbek madraimov)
print(ism_sharif.title()) #matindagi so'zlarni birinchi harifini katta b/n yozib chiqaradi(Umidbek Madraimov)
print(ism_sharif.capitalize())#matindagi matindagi birinchi so'zni katta bn yozib chiqaradi(Umidbek madraimov)
meva= ' Umidbek '
print("Mening ismim "+meva+"Madraimov") #(Mening ismim Umidbek Madraimov)
print("Mening ismim "+meva.lstrip()+"Madraimov")# matining chap tarafidagi bo'shliqni olib tashlaydi(Mening ismim Umidbek Madraimov)
print("Mening ismim"+meva.rstrip()+"Madraimov")#matinning ong tarafidagi bo'shliqni olib tashlaydi(Mening ismim UmidbekMadraimov)
print("Mening ismim"+meva.strip()+"Madraimov")# matindagi bo'shliqlarni olib tashlaydi(Mening ismimUmidbekMadraimov)
ism=input("Ismingizni kiriting: ")
print("Asolomu alekum "+ism.title()) #consulga kiritish input(Ismingizni kiriting: umidbek yangi qatorda -Asolomu alekum Umidbek)


Sonlar va matinlar:
#a=input("Sonni kiriting")
#print(type(a))# soni qaysi tipda ekenini chiqaradi
#x,z,a=15,46.3,866894846154 #sonlarni shu tartibda kiritish ham mumkin
#print("x= ",x)
#print("z= ",z)
#print("a= ",a)
#PI #katta harif bilan yozilgan son o'zgarmas son bo'lib hisoblanadi misol Uchun PI=3.14159
#ism=' omonboy '
#yosh=19
#print(ism.title()+str(yosh)+' yoshda')
#yosh=yosh+10
#print(ism.title()+str(yosh)+" yoshda")
t_yil=int(input('tugilgan yilingizni kiriting:'))# kiritilgan son string tipda edi int tipga toqazish
yoshi=2022-t_yil
print(yoshi #flout tipdagiga otkazish un flout() funksiyasidan foyddalaniladi

a=input("Sonni kiriting")


#print(type(a))# soni qaysi tipda ekenini chiqaradi
#x,z,a=15,46.3,866894846154 #sonlarni shu tartibda kiritish ham mumkin
#print("x= ",x)
#print("z= ",z)
#print("a= ",a)
#PI #katta harif bilan yozilgan son o'zgarmas son bo'lib hisoblanadi misol Uchun PI=3.14159
#ism=' omonboy '
#yosh=19
#print(ism.title()+str(yosh)+' yoshda')
#yosh=yosh+10
#print(ism.title()+str(yosh)+" yoshda")
t_yil=int(input('tugilgan yilingizni kiriting:'))# kiritilgan son string tipda edi int tipga toqazish
yoshi=2022-t_yil
print(yoshi #flout tipdagiga otkazish un flout() funksiyasidan foyddalaniladi
# #meva=['arik','shaptoli','anjir'] #list lar bn ishlash
# #narxi=[12,13,14,15,19,]
# #bosh_list=[]
# #print(meva)
# #print(narxi)
# #print(bosh_list)
# #print(meva[-1])
# #meva.append('olcha')#royhatni oxiriga element qoshadi
# #print(meva)
# #meva.insert(1,'Chiya') #royhatni nechanch raqamli elementiga element qo'shadi
# #print(meva)
# # meva[1] #indexsdagi elementni o'chiradi
# #print(meva)
# #meva.remove('anjir') #qaaysi elementni ochirish kerak bo'lganinda
# #print(meva)
# #xarojot=['gashir','piyoz','burunch','un','kartishka']
# #print(xarojot)
# #olingani=xarojot.pop(1)# garak elementni olish
# #print(olingani)
# #print(xarojot)
# print('mevalar orasidan ortiqchasini olib tashlang')
# mevalar=['anor','anjir','olma','Gashir','banan','arik']
# print("Mevalar orasidan ortiqchasini nechanchi turibdi")
# print(mevalar)
# n=int(input())
#
# ortiqcha_mahsulot=mevalar.pop(n-1)
# print("Ortiqcha mahsulot shumi: ")
# print(ortiqcha_mahsulot)
# print("Ortiqchasi olib tashlagandan keyingi natija: ")
# print( mevalar)
#
# m = list(map(int,input().split())) #kiritilgan soni int tipga ozgartiradi
# # a = input().split() # kiritilgan sonni list korinishida ifodalaydi
# print(m)

#m = [[[1,2,3,4],[1,2,3,4],[1,2,3,4]],[[1,2,3,4],[1,2,3,4],[1,2,3,4]],[[1,2,3,4],[1,2,3,4],[1,2,3,4]],[[1,2,3,4],[1,2,3,4]]] #massivni beerilishi


#for i in m:
#for i1 in i:
# for i2 in i1:
# print(i2,end=' ')
# print()

# print('\n')# chiqarilishi


STACK
# # n - chi elementdan keyin element qoshish
# # m = list(map(int,input("Ro'yxat elementlarini probel bilan ajratgan holda kiriting>>").split()))
# # q = int(input("boshiga qo'shiladigan elementni kiriting>>"))
# # n = int(input("N sonini kiriting>>"))
# # m.insert(n,q)
# # print("natija>> ",end="")
# # for i in m:print(i,end=" ")
# class Stack:
# def __init__(self):
# self.stack = []
# self.max = None
# self.max_ind =None
#
# def pop(self):
# if len(self.stack) == 0:
# return None
# removed = self.stack.pop()
# if len(self.stack) == 0:
# self.max = None
# elif removed == self.max:
# self.max = self.stack[0]
# n=0
# for value in self.stack:
# if value > self.max:
# self.max = value
# self.max_ind = n
# n+=1
# return removed
#
# def push(self, item):
# self.stack.append(item)
# if len(self.stack) == 1:
# self.max = item
# self.max_ind = 0
# if item > self.max:
# self.max_ind = len(self.stack)-1
#
# def get_max(self):
# return self.max
#
# def get_max_ind(self):
# return self.max_ind
#
# s_u = int(input('Stek uzunligini kiriting>>'))
# st = Stack()
# for i in range(s_u):
# n = int(input(f"{i+1}-element>>"))
# st.push(n)
#
# m = st.pop()
# st1 = Stack()
# st1.push(m)
#
# for i in range(s_u-1):
# n = st.pop()
# if n>m:m = n
# st1.push(n)
#
# st = Stack()
#
# for i in range(s_u):
# n = st1.pop()
# st.push(n)
# print(n)
# if n==m:
# st.push(0)
# print(0)
# hariflar=['a','b','c','s','d','ch','g','a','e','t','x','h','c','d','k','l','n','m']
# print('kiritilgan hariflar>>',hariflar)
# hariflar.sort() #ro'yhatni tartiblab chiqaradi
# print('Tartiblangan hariflar>>',hariflar)
# hariflar.sort(reverse=True) #teskari tartibda tartiblaydi
# print('teskari tartiblangan hariflar>>',hariflar)
#print(sorted(hariflar,reverse=False)) #asil ro'yhatni tartiblab chiqaradi
#print(sorted(hariflar,reverse=True)) #asil ro'yhatni teskari tartiblab chiqaradi
# hariflar.reverse()
# print('teskarisiga chiqqan hariflar>>',hariflar) #ro'yhatni teskari chiqaradi
#
# print(len(hariflar)) #ro'yhatni elementlar sonini chiqaradi
# sonlar=list(range(0,18)) # malum bir oraliqdagi sonlarni chiqaradi
# print(sonlar)
toq_sonlar=list(range(1,30,2)) #qadabni berish toq sonlarni chiqaradi
print(toq_sonlar)
# maxsimal=max(toq_sonlar)#sonning maksimal qiymatini topish
# print(maxsimal)
# minimal=min(toq_sonlar)#sonning minimal qiymatini chiqaradi
# print(minimal)
# jami=sum(toq_sonlar) #royhat elementlarini yig'indisini chiqaradi
# print(jami)
# keraki_sonlar=toq_sonlar[3:6]# 3:6 indeqs oraliqdagi sonlarni chiqaradi
# print(keraki_sonlar)
# keraki_sonlar_boshidan=toq_sonlar[:6]# ro'yxat boshidan 6 indeqsgacha chiqaradi
# print(keraki_sonlar_boshidan)
# keraki_sonlar_indexsdan_oxirigacha=toq_sonlar[3:] #ROYXATNI INDEXSDAN OXIRIGACHA CHIQARADI
# print(keraki_sonlar_indexsdan_oxirigacha)
# mening_toq_sonlarim=toq_sonlar # bir ro'yxatga 2 xil nom berish
# print(mening_toq_sonlarim)
# mening_toq_sonlarim.remove(25) #nusxalangan sonlar orasidan sonni olib tashlash
# print(mening_toq_sonlarim)
# mening_toq_sonlarim[0]=3 #elementni o'zgartirish
# print('mening_toq_sonlarim>>',mening_toq_sonlarim)
# print('toq_sonlar>>',toq_sonlar)
# toq_sonlar.append(957857) #ro'yxatni oxiriga elemeent qoshish
# print('toq_sonlar>>',toq_sonlar)
# print('mening_toq_sonlarim>>',mening_toq_sonlarim)
# mening_toq_sonlarim=toq_sonlar[:] #ro'yxatdan nusxa olish
# mening_toq_sonlarim.remove(25)
# print('mening toq sonlarim>>',mening_toq_sonlarim)
# print('kiritilgan toq sonlar>>',toq_sonlar)
#TUPLE #O'ZGARMAS RO'YXAT
Jasminaga_qoyinchoqlar=('ayiq','qochoq','moshin','traktr','ot')
print(Jasminaga_qoyinchoqlar)
Jasminaga_qoyinchoqlar=list(Jasminaga_qoyinchoqlar)#element qoshish uchun listga o'zgartirib oldik
print(type(Jasminaga_qoyinchoqlar)) #Royxat qaysi tipda ekanini bilish
Jasminaga_qoyinchoqlar.append('eshak')
print(Jasminaga_qoyinchoqlar)
Jasminaga_qoyinchoqlar=tuple(Jasminaga_qoyinchoqlar) #o'zgaruvchan ro'yxatni o'zgarmasaga aylantirish
print(type(Jasminaga_qoyinchoqlar)) #ro'yxatni tipini aniqlash
Proyekt
import turtle
tu=turtle.Turtle()
tu.screen.bgcolor("red")
tu.pensize(2)
tu.color("green")
tu.left(90)
tu.backward(100)
tu.speed(200)
tu.shape('turtle')
def tree(i):
if i<10:
return
else:
tu.forward(i)
tu.color("orange")
tu.circle(2)
tu.color("brown")
tu.left(30)
tree(3*i/4)
tu.right(60)
tree(3*i/4)
tu.left(30)
tu.backward(i)
tree(100)
turtle.done()
Download 112.32 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling