تمرین برنامه نویسی؛ با کدبزن!

منبع جامع سوالات و تمرینات برنامه نویسی

2
+1
+1

بررسی کدپستی

Admin آسان 83/ دانلود 1139 بازدید

تابعی بنویس که کدپستی کاربر را به عنوان پارامتر دریافت کند و بررسی کند که کدپستی صحیح است یا خیر؟

کدپستی باید 15 رقم باشد
کدپستی فقط شامل اعداد است

21 جواب

نمیتونم این تمرین رو حل کنم!
3
+1
+1
+1
def PostalCode(code):
    res = bool()
    code = str(code)
    if code.isdigit()==True and len(code)==15:
        res = True
    else:
        res = False
    return res
Unknown دانلود Python
2
+1
+1
def cod(post) :
    
    if len(m) == 15 and m.isdigit():
        return "cod posti dorost ast"
    
    return 'cod posti bayad 15 ragam va fagat adad bashad'

m =(input('cod:\n'))
print(cod(m))
Rtmobin دانلود Python
1
+1
def checkcodeposti(code):
    if len(code) == 15:
        if code.isdigit():
            return True
    return False

i = input('code:')
print(checkcodeposti(i))
Hossein دانلود Python
1
+1
def code(p):
    return True if len(p)==15 and p.isdigit() else False
CP=input('code posti: ')
print(code(CP))
Zb8319 دانلود Python
1
+1
def post_code(code):
    return len(code) == 15 and code.isdigit()


i=input('Enter post code:')
print(post_code(i))
کاربر 468 دانلود Python
1
+1
postal_code =input('enter your post code : ')
def check_code(a):
    if len(a)<=15 and a.isdigit()==True :
        return("postal code is true")
    else :
        return ('postal code is false')
    
print(check_code(postal_code))
Knowledgebiome دانلود Python
0
while 1:
    def check(code):
        if len(code) == 15 and code.isdigit():
            return True
        return False
    code = input("enter codeposti: ")
    if code == "0":
        break
    print(check(code))

Aryan84 دانلود Python
0
code = input('please enter your Postal code : ')
if len(code) == 15 and code.isnumeric() == True:
    print('Your Postal code was true.')
else:
    print('Your Postal code was wrong.')
Astehal دانلود Python
0
code=input("entwer code:")
def codepost(code):
    if  len(code)==15 and code.isdigit():
        return "true"
    else:
        return "false"
    

output=codepost(code)     
print(output)  
Amirowich دانلود Python
0
def validate_postal_code(postal_code):
    if len(postal_code) == 15 and postal_code.isdigit():
        return True
    else:
        return False

cd_post = input('post: ')
result = validate_postal_code(cd_post)
print(result)
Hamed دانلود Python
0
print("faghat bayad shamel adad bashad va tedad argham bayad 15 ragham bashad,ba tashakor.")
code=(input("zip-code: "))
if len(code)==15 and code.isdigit():
    print(code,"It's correct")
else:
    print("It's not correct")
Mahan78 دانلود Python
0
def PC(pc):
    if pc.isalnum()==True and len(pc)==15:return True
   else:return False
Ordinaryperson دانلود Python
0
def checkCode(num):
    if len(num) != 15:
        print("Error!!! your code must be 15 digit")
    elif num.isnumeric() == False:
        print('Error!!! your code must be only digit')
    else:
        print('Congratulations!!! your postal code is correct')

while True:
    code = input("Please enter your postalcode:")
    checkCode(code)
F2030 دانلود Python
0
def post_code(Code):
    if Code.isalpha():
        print("Enter number!")
    elif len(Code) == 15:
        print("Correct")
    elif len(Code) < 15:
        print("It's less. Enter more numbers(Just fifteen digits).")
    elif len(Code) == 16:
        print("It's more. It's not a standard postcode(Just fifteen digits).")

post_code(input("Enter your postcode:"))
Javadmirjalili دانلود Python
0
def code(posti):
    return len(posti) == 15 and posti.isnumeric()
x =input('enter your postcode : ')
print(code(x))
کاربر 1224 دانلود Python
0
def cod_p(a):
    if len(a) == 15 and a.isdigit() :
        return True
    
    return False

i = input('Code posti : ')
print(cod_p(i))
Pooria08 دانلود Python
0
a= input('code post:\n')
x=a.isnumeric()
if x==False:
    print(''' you most write number's just💢''')
    exit()
if len(a)<15 or len(a)>15:
    print(' code post is not corect❌')
if len(a)==15:
    print('cotect✅')
Hadiozan20 دانلود Python
0
def cod(m):
    if len(m)==15 and m.isdigit():
        print(True)
        return(m)
    else:
        print(False)
k=input("num...>")
print("your code is:",cod(k))

Mary12 دانلود Python
0
i=input('kodposti: ')
def cod(s):
    if len(s)==15 and s.isdigit() :
        return True
    return False
     
print(cod(i))
کاربر 1910 دانلود Python
0
def postalCode() : 
    post=input('postal code : ')
    if post.isnumeric() and len(post)==15 : 
        print('welldone')
    else : 
        print('invalid')    
postalCode()        
Soheyl دانلود Python
0
import string
def post_Code(n):
    s=(string.digits)
    l=len(n)
    if len(n) != 10:
        return False
    else:
        r=[]
        for i in (n):
            if i not in s:
                r.append(i)
        if len(r)==0:
            return True
        else:
            return False


def post_Code2(n):
        if n.isdecimal() and len(n) ==10:
            return True
        return False
               
        
n=input ("n: ")


print (post_Code(n))
print (post_Code2(n))
Aligheisari دانلود Python

ارسال جواب

/* کداتو توی این بخش بنویس
فرقی نمیکنه چه زبان برنامه نویسی باشه، همرو پشتیبانی میکنیم :)
البته قبلش این سه خط رو پاک کن */


  • تو جوابت میتونی از تصویر، کد، لینک به سایر صفحات و... استفاده کنی
  • لطفا جواب های تکراری ارسال نکن
  • جواب های ارسالی، پس از بررسی کوتاهی، ویرایش میشن و در سایت نمایش داده میشن
  • ارسال جواب حق مادی یا معنوی برای ارسال کننده ایجاد نمیکند و تمام حقوق برای سایت کدبزن محفوظ است

تمرینات مرتبط

تشخیص با استفاده از هوش مصنوعی
×
×
بستن