Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

i can't get the fourth part of my code to work in python

My python code is below but when I run the part under mark==4 it wont print the results can I have some help please? I tried to use the propper characters aswell but when I used the unicode encoding and decoding prompts it displayed the error "cant print bytes only strings"

mark=int(input('which assignment do you want to mark assignment 1,2,3,4,or 5'))
if mark==1:
    print('you have chosen to mark assignment 1')
    temp=int(input('what is the temperature outside your home at this verry moment?
' ))
    if temp<=0:
        print('wow its so cold that the water in the pond is frozen')
    if 0<temp>10:
        print('its coat weather you idiot what are you thinking wearing shorts and a t-shirt')
    if 11<temp<=20:
        print('a sweater may be needed')
    if 21<temp<=26:
        print('its quite nice outside')
    if 27<temp<=32:
        print('FINNALY SUMMER IS BACK!!!!!!')
    if temp>33:
        print('i-t-s s-o-o-o h-o-t *you pass out*')
if mark==2:
    print('ok so you have chosen assignment 2 now we are getting a litle bit more complex')
    while True:
        try:
            numbers=input('please type a <NUMBER> that is positive ore negative')
            numbersint=int(numbers)
            if not numbers.isdigit==True:
                break
                
                
        except Exception:
                print('A NUMBER YOU DIMWIT')
                continue
    if numbersint<0:
        print('ok so we are being negative i see')
    if numbersint>=0:
        print('now were talking be positive all the way')
if mark==3:
    print('YAY ASSIGNMENT THREE LETS GET GOING!!!')
    from datetime import *
    print('input your date of birth in this format YYYY MM DD')
    hola = datetime.strptime(input("--->"), "%Y %m %d")

    def calculateage(BirthDate):
        today= date.today()
        return today.year - BirthDate.year - ((today.month, today.day) < (BirthDate.month, BirthDate.day))
    my_age = calculateage(hola)
    print(my_age)
        
    
if mark==4:
    lang=input('what is your language? jap for japaneese, span for shanish, iri for irish, ital for italian, chin for chineese, ')
    if lang.lower == 'jap':
        jap="Gokigen'yō!"
        print('oh', jap)
    if lang.lower=='chin':
        chin="Zhù nǐ jīntiān yúkuài!"
        print('oh', chin)
    if lang.lower=='span':
        span="?Que tengas un buen día!"
        print('oh', span)
    if lang.lower=='iri':
        iri="Lá maith agat!"
        print('oh', iri)
    if lang.lower=='ital':
        ital="Buona giornata!"
        print('oh', ital)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...