I want to create a branch based on the contents of the variables entered in input.

Asked 1 years ago, Updated 1 years ago, 91 views

My first programming was Python, and I'm a super beginner with a day of Python history.
Based on height and weight, we have created a program that determines whether you are overweight, just right, or overweight.It went well over there.Now we're writing a program that translates arc and frequency methods into one another.

I don't want elegance at all right now, but my goal is to make it work for now.

 from path import pi

uses pi as a 16-digit approximation, but I would like to create other module features without importing them.
Give me some advice.

It's my first day of self-taught groping, so I'm overwhelmingly lacking in knowledge.

defangle():
    to_radian=input("Conversion from frequency to arc?y/n")
    '''
    If the answer is y/n in the input above and the answer is y, I would like you to convert the frequency method from the frequency method to the arc degree method, or to convert the arc degree method to the frequency method.The description is ↓, and if to_radian=y causes syntax errors.I thought it was suspicious, but I'm not used to dealing with variables yet, so I don't know why.Also, I didn't go ahead due to an error, so I don't have any self-sufficiency after that.
    '''

    if to_radian=y:
        angle=input("Enter the angle using the frequency method.")
        angle_to_radian_coef=int(angle)/180
        angle_to_radian=int(angle_to_radian_coef)*pi
        print("+str(angle)+"°"+" is "+str(angle_to_radian)+" radian in arcs.")
        print(" +"+str(angle_to_radian_coef)+" ラ radians."

    else:
        radian=input("Enter the angle using the arc".However, please omit は and enter only the coefficient.
    Yes.")
        radian_to_angle=int(radian)*180 
        print("+srt(radian)+" ""+" is "+str(radian_to_angle)+"°" in the frequency method.           

# So far, we have defined the function with def.Do it below.

angle()

python3 numpy

2022-09-30 21:42

1 Answers

If you are writing the contents so far on your own, I feel that if you don't panic and decipher the error, you will have the ability to make it work.
First, calm down and review the code around the error and past programs.

  • SyntaxError: invalid syntax (occurs in the first if statement)
    • = is replace and use == for comparison
      to_radian=y substitutes the variable y for the variable to_radian
  • NameError: name 'y' is not defined
      The
    • variabley is not defined. Rewrite to "y" and compare to string
  • NameError: name 'srt' is not defined
    • str is not mistaken for srt
  • SyntaxError: invalid syntax ( else: or lower)
    • Remember to close the print() parentheses (there are two parts that are not closed)
  • = is replace and use == for comparison
    to_radian=y substitutes the variable y for the variable to_radian
    The
  • variabley is not defined. Rewrite to "y" and compare to string
  • str is not mistaken for srt
  • Remember to close the print() parentheses (there are two parts that are not closed)

If you rewrite it as advised, you will be able to run it without any compilation errors.
However, this may result in digit drops or input errors in conversion to int type.

  • Enter 90 in degree to radian

    90° is 0.0 radians in the degree method.

  • Enter 1.57 in radian to degree

    ValueError: invalid literal for int() with base 10: '1.57'

90° is 0.0 radians in the degree method.

ValueError: invalid literal for int() with base 10: '1.57'

I think the above output is different from the purpose, so please do your best while reviewing int and float.

"By the way, the specific questions are described in the comment ""input above"" in the code, but I think it would be easier to get answers if you write them in the questionnaire as you can see the problem at a glance before reading the code carefully."


2022-09-30 21:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.