0% found this document useful (0 votes)
5 views2 pages

Unit 1sample Programs

The document outlines a series of sample programming exercises divided into two weeks. Week 1 focuses on basic programming concepts such as identifiers, arithmetic, logical, and bitwise operations, while Week 2 includes programs for number classification, printing sequences, and user interaction based on travel distance. Additionally, it includes a program for calculating server operation costs.

Uploaded by

kodurusailalitya
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)
5 views2 pages

Unit 1sample Programs

The document outlines a series of sample programming exercises divided into two weeks. Week 1 focuses on basic programming concepts such as identifiers, arithmetic, logical, and bitwise operations, while Week 2 includes programs for number classification, printing sequences, and user interaction based on travel distance. Additionally, it includes a program for calculating server operation costs.

Uploaded by

kodurusailalitya
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

Sample programs

Week 1
1. Program to demonstrate valid and invalid identifiers
2. Program to perform arithmetic operations (x = 10, y = 4)
3. Program to perform assignment operations
4. Program to perform logical operations
5. Program to perform comparison or relational operations
6. Program to perform bitwise operations (10&4), (7|9),
(4^7), (~4)
7. Program to demonstrate operator precedence and
associativity
8. Program to display different data types in Python
9. Program to show single-line and multi-line comments
10. program to print name, country, state and district
using format and f- strings
Week 2
1. Write a program to check if a given number is Positive,
Negative, or Zero.
2. Write a program to check if a given number is odd or
even.
3. Write a program to print numbers from 1 to 10 in a
single row with one tab space.
4. Write a program to print even numbers between 23 and
57. Each number should be printed in a separate row.
5. Write a program to print sum of all the numbers of a
given number.
6. Write a program to print to reverse a given number and
print
7. Given two non-negative values, print true if they have
the same last digit, such as with 27 and 57.
lastDigit(7, 17) → true
lastDigit(6, 17) → false
lastDigit(3, 113) → true
8. Create a python program that asks the user how
far they want to travel.
If they want to travel less than three miles tell them to
ride Bicycle.
If they want to travel more than three miles, but less
than three hundred miles, tell them to ride Motor-
Cycle.
If they want to travel three hundred miles or more tell
them to drive Super-Car.
9. Write a Python program that displays the answers to the
following questions:

a. How much does it cost to operate one server per day?


b. How much does it cost to operate one server per week?
c. How much does it cost to operate one server per month?
d. How many days can I operate one server with $918?

You might also like