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

CS - Python Coding - Practice Questions

Uploaded by

dinaabdulrasoul
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)
4 views2 pages

CS - Python Coding - Practice Questions

Uploaded by

dinaabdulrasoul
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
You are on page 1/ 2

Functions:

Question 1:
Create a function that checks if a number is even or odd.

Question 2:
Create a function that calculates the area of a rectangle.

Question 3:
Create a function to find the sum of all elements in a list.

File Handling:
Question 1:
Numbers.txt contains a list of integers.
Write a program to implement these requirements:
 Read the integers from Numbers.txt.
 Identify and count how many of them are even.
 Write the even numbers to Evens.txt.
The program must:
 Use loops to process the file data.
 Write only the even numbers into Evens.txt.
Question 2:
Words.txt contains a list of words.
Write a program to implement these requirements:
 Read each word from Words.txt.
 Check if the word contains more than 5 characters.
 Print all words longer than 5 characters to the screen.
The program must:

© Eng. Dina Abdulrasoul


 Use loops to process the words in the file.
 Only print words that satisfy the condition.

Question 3:
Temperatures.txt contains daily temperature readings in Celsius.
Write a program to implement these requirements:
 Read each temperature from Temperatures.txt.
 Identify any readings below 0°C and count them.
 Write these sub-zero readings to Freezing.txt.
The program must:
 Use loops to process the temperatures.
 Write only the readings below 0°C into Freezing.txt.

© Eng. Dina Abdulrasoul

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy