0% found this document useful (0 votes)
15 views

Python File Codes Set 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Python File Codes Set 1

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Practical File Codes

Class X Artificial Intelligence


I) if() statement
1) Write code to check whether a number is an odd or even number.
2) Write code to check whether a number is a positive or negative number
3) Write a code to check whether a letter entered by the user is a vowel or consonant.
4) Write a code to print the day of the week according to the week number entered by the
user. (1 - Sunday, 2 - Monday, ….)
5) Write code to print grade according to the following criteria of the percentage.
91-100 - A1 51-60 - C1
81-90 - A2 41-50 - C2
71-80 - B1 <40 - Needs Improvement
61-70 - B2

I) for() statement
1) Print ‘n’ multiples of ‘m’.
2) Ask user to enter ‘n’ numbers and then check all the numbers to be odd or even.
3) Write code to check if a number is odd or even. If it is odd, print its next n
consecutive numbers. If it is even, print its next n multiples.
4) Print the following series: 1/2., 2/4, 3/9. ---- n/n2
5) Print square of ‘n’ numbers in the following format:
1x1=1
2x2=4
.
.
n xn =n2
III) while() statement
1) Print sum of first n odd numbers.
2) Print user name number of times he wants
3) Write code to accept numbers till the time user keeps saying “yes”. In the end print the
sum of all the numbers and the total number of times the user typed “yes”.
4) Print the following pattern
*
**
***
****
5) Give one example of infinite loop

You might also like