0% found this document useful (0 votes)
3 views3 pages

Ece 262 Lecture

The document provides a series of examples and practice questions related to basic Python programming concepts, including printing, string manipulation, user input, conditional statements, and functions. It includes specific tasks such as checking eligibility to vote based on age, determining divisibility, and calculating attendance percentages. The practice questions encourage users to implement these concepts in various programming scenarios.

Uploaded by

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

Ece 262 Lecture

The document provides a series of examples and practice questions related to basic Python programming concepts, including printing, string manipulation, user input, conditional statements, and functions. It includes specific tasks such as checking eligibility to vote based on age, determining divisibility, and calculating attendance percentages. The practice questions encourage users to implement these concepts in various programming scenarios.

Uploaded by

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

ECE 262

1. Printing in Python:
Examples: print the following
❖ My father’s house is big. I’m proud of it
❖ * * *
*
*
2. Python Strings:
Examples:
❖ greet = ‘Hello, Class’. Print characters from position 1 to 4. Print characters from
position 7 to the end making sure the printed characters are all capital letters.
❖ a=’Hello’, b = ‘Class’. Print the word to appear as: Hello, Class.
Print the word to appear as: Hello my Classmates.
❖ a = 4, b= 272. Print: I have 4 gallons of water in room 272.

3. Accepting input from user and if else statements:


Examples:
❖ Accept two int values from user and print the greatest among them
❖ Write a program that accepts student score from user and prints the persons grade
e.g if student score entered is 70, the program should print A.

4. Functions:
Examples:
❖ write a function that can calculate the area of rectangle.
❖ Write a function that checks if a number is an even or odd number. It should print
‘even’ if the number is even, otherwise it should print ‘odd’.
PRACTICE QUESTIONS

A. Write a program that allows a user to enter his/her age to check his/her eligibility to vote.
Print ‘Eligible, kindly cast your vote’ if entered age is greater than 18, otherwise print
‘Ineligible, please come back when you are 18’.

B. Write a program that accepts input from user. Print True if entered value is divisible by 5,
otherwise print False.

C. Write a program that accepts two inputs from a user. Print the greater number or print ‘The
numbers are equal’. E.g if entered value is 4 and 7, print 7. If entered number is 8 and 8,
print ‘‘The numbers are equal’’.

D. Write a program that accepts an input from a user. Print ‘Even number’ if entered value is
even or print ‘Odd number’ if entered value is odd. You must make sure the entered value
is a number. If the entered value is not a number, print ‘Enter a valid number’.

E. Coca Cola recently announced a discount of 10% if a customer buys Coke worth more than
1000 Naira. If one coke costs 200 Naira. Write a program that allows the customer enter
the quantity of coke he/she wants to buy. Then calculate and print the amount the customer
is expected to pay. E.g if a customer wants to buy 7 cokes, print ‘1260 Naira’.

F. In UNN regulation, a student will not be allowed to sit for an examination if his/her
attendance is less than 75%.

Take the following input from user:


1. Number of classes held
2. Number of classes attended
Print the percentage of attendance and his/her eligibility. Eg if number of classes held =
10 and the student attended 8 classes. Print ‘Your percentage attendance is 80%, you are
eligible’. if number of classes held = 10 and the student attended 6 times. Print ‘Your
percentage attendance is 60%, you are Ineligible’.

You might also like