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

Programming Fourth Batch (Iteration) 30-44

The document provides instructions for 44 programming tasks involving loops and conditionals. The tasks include printing numbers from 0 to 20 using a while loop, calculating the average of 10 input numbers, printing odd numbers from 1 to 20, generating multiplication tables, calculating factorials, powers, digit sums, counting vowels/consonants in input text, calculating products of ranges, converting between binary and decimal, finding maximum/minimum values, calculating Collatz sequences, summing ranges with certain exclusions, and checking for prime numbers. Loops and basic math/comparison operations are required, without using built-in functions when not permitted. Careful testing of logic is emphasized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Programming Fourth Batch (Iteration) 30-44

The document provides instructions for 44 programming tasks involving loops and conditionals. The tasks include printing numbers from 0 to 20 using a while loop, calculating the average of 10 input numbers, printing odd numbers from 1 to 20, generating multiplication tables, calculating factorials, powers, digit sums, counting vowels/consonants in input text, calculating products of ranges, converting between binary and decimal, finding maximum/minimum values, calculating Collatz sequences, summing ranges with certain exclusions, and checking for prime numbers. Loops and basic math/comparison operations are required, without using built-in functions when not permitted. Careful testing of logic is emphasized.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Programming Assignment

Fourth Batch
Iteration / loop
Notes:

• You will only use While Loop for all these questions solutions, for loop is not allowed.
• You will not treat a number as a string in any of the question.
• Do not use a built In function without permission.
• If a program requires you should test it multiple times to make sure the complete
functionality of the code.

Task # 30 : Write a program to print all numbers from zero to 20 with a while loop.

Task # 31 : Write a program to input 10 numbers and print the average of these 10 numbers.

Task # 32 : We are writing a program to print all odd numbers between 1 and 20 inclusive.

Task # 33 : Write a program to input a number and print the multiplication table of this number in the
given format from 1 to 12.

for example Input 7 Output would be

1*7=7

2 * 7 = 14

12 * 7 = 84

Task # 34 : Write a program to input a number and print its factorial.

5! means 5*4*3*2*1 = 120.

Task # 35 : Write a program to input 2 numbers A,B. Find the product of these numbers without using
the multiplication operator.

if A = 5 , and B = 4 output 20
Task 36 : Write a program to input two numbers, B and P. Find B raised to the power of P. For example if
B = 3, and P = 4 your output should be 81. You cannot use the power (**) operator in python and (^)
operator in pseudocode.

Task # 37 : Write a program to input a number, (no fixed digits) , print the sum of its digits.

152 => 8 is sum

92 = 11 is the sum

9018 = 18 is the sum

Task # 38 : Input characters and stop when a full stop is entered. Print the number of vowels and
consonants entered. Do not accept any non-characters and give an error if entered. Accept both lower
case and upper case alphabets.

Task # 39 : Input two numbers A and B. Find the product of all numbers between A and B inclusive.

A = 2, B = 5

2 * 3 * 4 * 5 = 120

Task # 40: Input a denary number and convert and print its binary equivalent. You cannot put any limit,
your logic must work for any positive number. The resultant binary number may be a string but the
input must be a denary number and not a string. You must read the modulus 2 method of converting
denary number to binary from your book.

Task # 41: Input numbers and stop when zero is entered. Print the largest and smallest positive number
entered by the user. Print the percentage of negative numbers entered. Zero is the rogue value that will
stop your program.

Task # 42: Collatz Sequence. Start with any number but you will reach to 1. If the number is Even the
next term is the number Divide by two if the number is Odd then the next term is 3*N + 1. Print the
sequence. Start will be input by user. Given below is an example of Collatz sequence that started from
seven.

Input : 7

7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8 ,4 ,2 ,1

Learn how to print multiple time in the same line. Your google search string will be

“print in same line in python”


Task # 43: Input two numbers. Find the sum of all numbers between these two numbers including the
entered ones. Do not include any number that is a factor of 3 or 5. But if it is a factor of both then
include it for example

n1 = 9, n2 = 20

11+13+14+15+16+17+19

Your result should be 105

Task # 44 : Input a number and print if it is a Prime number or not. A Prime number is the one that is
only divisible by 1 and itself. Your program should work with logically any positive number(no limit).

Check with 199 and 235.

You might also like