0% found this document useful (0 votes)
26 views6 pages

Lab 11

Uploaded by

aaliyahhhh.xs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

Lab 11

Uploaded by

aaliyahhhh.xs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

INFS 1101 – Lab 11

Instructions
The lab consists of two parts:
 Part I consists of fundamental exercises: you need to complete, understand, and
submit these exercises by midnight.
 Part II consists of additional exercises that you need to finish in the next 2 Days and
submit it.

For this lab, you will need to develop the code for each exercise. the code should be developed in IDLE.
Make sure to include comments in each of your Python files indicating your name, student ID, course
and section #, and name of the program.
Once you are done, put all your Python (.py) files in two zipped folders ( Lab11-part1.zip) and (Lab11-
part2.zip) , submit both parts in the same D2L dropbox.

Part I
Exercise 1
Write a program that will determine the Chinese Zodiac for a given year. Specifically, your program
should prompt the user to enter a year and then determine the Zodiac and display the results.
The Chinese zodiac sign is based on a 12-year cycle, and each year in this cycle is represented by an
animal: monkey, rooster, dog, pig, rat, ox, tiger, rabbit, dragon, snake, horse, and sheep. Here is a
sample run:

 Input validation: the year should be a positive integer, or else keep asking the user for his input
until he enters a valid one,

Sample run 1:
Enter the year: -1987
Enter a valid year
Enter the year: -500
Enter a valid year
Enter the year: 1987
You are a Rabbit

Sample run 2:
Enter the year: 0
Enter a valid year
Enter the year: -455
Enter a valid year
Enter the year:1955
You are a sheep
Exercise 2
Problem: Write the Python code of a program called FavoriteHobby that asks the user to type in their
favorite hobby and a short sentence describing what is so special about that hobby. Display to the user
the first 10 characters and the last 10 characters of the sentence they typed. Use the len() function to
get the range of the last 10 characters, note the following:

 Input validation: Both the name and the hobby should be at least 3 characters longs, or else
keep asking the user for his input until he enters a valid one,
 Use the .capitalize() function to capitalize the first letter of the user name in your print
statements.

Sample run:
What is your name? ze
Name must be more than 3 characters. Try again.
What is your name? zeina
What is your favorite hobby? Te
Hobby must be more than 3 characters. Try again.
What is your favorite hobby? Tenis
What is so special about tennis? I love the challenge!
Zeina, the first 10 characters you typed are: ‘I love the’, and the
last 10 characters you typed are:‘challenge!’.Part II
Exercise 3
Problem: Write the Python code of a program called UniversityApplication that asks the user to enter
their name, age, and high school GPA. If the user is at least 18 years old and their school GPA is at least
2.75, display a message telling the user they are eligible to apply to study that major. However, in case
the user’s GPA is below 2.75, display a message telling them that they are not eligible to apply to study
at this university. If the user is 17 or 16 years old, and has a GPA of at least 3.0, display a message telling
them they can apply for exceptional acceptance. However, in case the user’s GPA is below 3.0, display a
message telling them that they are not eligible to apply to study at this university. If the user is younger
than 16, tell them they must wait until they are older to apply. note the following:

 Input validation: the name should be at least 3 characters longs, the age should be number
greater than 0, the GPA should be 0 or above, or else keep asking the user for his input until he
enters a valid one,

Age >=18
GPA>=2.75 GPA<2.75
Accepted Rejected

Age =16 or Age = 17


GPA>=3 GPA<3
Accepte Rejected
d

Age < 16
Rejected

Sample run 1:
What is your name? ze
Name must be more than 3 characters. Try again.
Please enter your name: zein
Welcome, Zein. How old are you? 0
Please enter a valid age
Welcome, Zein. How old are you? -4
Please enter a valid age
Welcome, Zein. How old are you? 18
What is your high school GPA? -47
Please enter a valid GPA
What is your high school GPA? 2.85
Good news, Zein! You are eligible to apply to study at this
university.

Sample run 2:
What is your name? Sa
Name must be more than 3 characters. Try again.
Please enter your name: samy
Welcome, Samy. How old are you? 0
Please enter a valid age
Welcome, Samy. How old are you? -6
Please enter a valid age
Welcome, Samy. How old are you? 18
What is your high school GPA? 2.4
Sorry, Samy! Your GPA is too low. You are not eligible to apply to
study at this university.

Sample run 3:
What is your name? da
Name must be more than 3 characters. Try again.
Please enter your name: diana
Welcome, Diana. How old are you? 0
Please enter a valid age
Welcome, Diana. How old are you? 16
What is your high school GPA? 3.5
Good news, Diana! You are quite young, but you have a great GPA score.
You may apply for exceptional acceptance at this university.

Sample run 4:
Please enter your name: yara
Welcome, Yara. How old are you? 17
What is your high school GPA? -6
Please enter a valid GPA
What is your high school GPA? 2.85
Sorry Yara! You are quite young, and your GPA score is below 3.0. You
are not eligible to apply to study at this university.

Sample run 5:
Please enter your name: greg
Welcome, Greg. How old are you? 14
What is your high school GPA? 2.8

Remember to include your name, student number, and other relevant information as
comments in each of your Python files. Not doing so can result in no grade for that
submission.

You might also like