Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Python i need help to figure out his code

ak.hxssxn

Coder
[UWSL][UWSL]Ask the user to enter the employee name and years they had worked for[/UWSL][/UWSL]
[UWSL][UWSL]If they worked for more than two years, they're eligible for EI and print a statement telling them that.[/UWSL][/UWSL]
 
Hi there! Welcome to Code Forum!

I’m not too familiar with Python but let’s find out together! So from what I read you need some sort of listener or input then you will need a variable to store that information. Then throw it through an if statement which will then display if the person is eligible for EI.
 
Last edited:
Hey there.

I don't use Python at all, but working off of my knowledge, and a book as a reference, I have managed to create a program based on what you want to do:

Python:
# User input program.                                                                                                   
                                                                                                                        
Employee_Name = input("Please insert the name of the employee: ")                                                       
Employee_Years = input("Please insert how many years of experience the employee has: ")                                 
                                                                                                                        
Employee_Years = int(Employee_Years) # Treat the Employee_Years variable as an integer value.                           
                                                                                                                        
print("Employee Name: " + Employee_Name)                                                                                
# Note: Use str() in this print statement to convert it back to a string.                                               
print("Employee Experience: " + str(Employee_Years) + " years")                                                         
                                                                                                                        
# Check to see if the employee is eligible.                                                                             
if Employee_Years >= 2:                                                                                                 
     print("You're eligible.")                                                                                          
else:                                                                                                                   
     print("Sorry, but you aren't eligible.")        File Edit Options Buffers Tools Python Help                                                                             
# User input program.                                                                                                   
                                                                                                                        
Employee_Name = input("Please insert the name of the employee: ")                                                       
Employee_Years = input("Please insert how many years of experience the employee has: ")                                 
                                                                                                                        
Employee_Years = int(Employee_Years) # Treat the Employee_Years variable as an integer value.                           
                                                                                                                        
print("Employee Name: " + Employee_Name)                                                                                
# Note: Use str() in this print statement to convert it back to a string.                                               
print("Employee Experience: " + str(Employee_Years) + " years")                                                         
                                                                                                                        
# Check to see if the employee is eligible.                                                                             
if Employee_Years >= 2:                                                                                                 
     print("You're eligible.")                                                                                          
else:                                                                                                                   
     print("Sorry, but you aren't eligible.")

I'm not sure if it's exactly what you want, but as I've said, I've written it based on your needs. Ask the user for the name of the employee and how many years of experience they have, and then check to see if they're eligible for whatever.
 
@Mathematical is on the right track.
input() allows the user's response to be saved to the variable, which then allows you to analyze whether it is over or equal to 2.
One thing worth mentioning though is that you should restrict the type of answer they can give, to prevent non-numbers. The code above will error out or may have unexpected results if someone types in the letter "a" for example instead of a number. He does cast the variable to an integer using int(), but there is no error displayed (with question re-asked) if they type in a non-number.
 
Hi there! Welcome to Code Forum!

I’m not too family with Python but let’s find out together! So from what I read you need some sort of listener or input then you will need a variable to store that information. Then throw it through an if statement which will then display if the person is eligible for EI.
thank you!
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom