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

conditional and loop

The document outlines five Python programming tasks: guessing a number between 1 and 9 with user prompts, constructing a specific pattern using nested loops, counting even and odd numbers in a series, printing item types from a list, and calculating a dog's age in dog years based on human years. Each task includes a brief description and expected outputs. These exercises aim to enhance Python programming skills through practical applications.

Uploaded by

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

conditional and loop

The document outlines five Python programming tasks: guessing a number between 1 and 9 with user prompts, constructing a specific pattern using nested loops, counting even and odd numbers in a series, printing item types from a list, and calculating a dog's age in dog years based on human years. Each task includes a brief description and expected outputs. These exercises aim to enhance Python programming skills through practical applications.

Uploaded by

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

1. Write a Python program to guess a number between 1 and 9.

Note : User is prompted to enter a guess. If the user guesses wrong then the prompt appears
again until the guess is correct, on successful guess, user will get a "Well guessed!" message,
and the program will exit.

2. Write a Python program to construct the following pattern, using a nested for loop.

3. Write a Python program to count the number of even and odd numbers in a series of
numbers
Sample numbers : numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
Expected Output :
Number of even numbers : 5
Number of odd numbers : 4

4. Write a Python program that prints each item and its corresponding type from the following
list.
Sample List : datalist = [1452, 11.23, 1+2j, True, 'w3resource', (0, -1), [5, 12], {"class":'V',
"section":'A'}]

5. Write a Python program to calculate a dog's age in dog years.


Note: For the first two years, a dog year is equal to 10.5 human years. After that, each dog
year equals 4 human years.
Expected Output:
Input a dog's age in human years: 15
The dog's age in dog's years is 73

You might also like