• 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.
    • 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

New Coder
May 18, 2020
8
2
4
Ask the user to enter the employee name and years they had worked for
If they worked for more than two years, they're eligible for EI and print a statement telling them that.
 
  • Like
Reactions: Master Yoda

Master Yoda

Administrator
Administrator
Verified
Jan 2, 2018
1,720
432
95
Canada
codeforum.org
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:

Mathematical

Coder
Mar 30, 2020
145
20
18
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.
 
  • Like
Reactions: Ghost

Ghost

Active Coder
Apr 19, 2019
407
184
43
@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.
 

ak.hxssxn

New Coder
May 18, 2020
8
2
4
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!