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

CS111 2020 Assignment3

Uploaded by

qwer353666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

CS111 2020 Assignment3

Uploaded by

qwer353666
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CS111: Fundamentals of CS

Year 2020/2021
Faculty of Computers and Artificial Intelligence

CS111 Fundamentals of CS
Year 2020-2021

Assignment 3: Python Programming Assignment


➢ Dr Khaled Tawfik
➢ Dr Sabah Sayed
CS111: Fundamentals of CS
Year 2020/2021
Faculty of Computers and Artificial Intelligence

Important Instructions:
• Write a readable code for each of the following problems with a screenshot for the
output.
• Deadline for submission will be Thursday 14-1-2021
• No late submissions will be accepted.
• Discussion of assignment will be in your TA’s office hours.
• You should understand everything in your answers during the discussions with your
TA, otherwise you will be graded by negative.
• Cheaters and copies will be graded by negative.
• Assignment should be solved individually.
• You should write your answers into word file.
• You should submit the word file with the following name format: Group_ID_Name
(for example: S1_20200001_Ahmed Mohamed)
CS111: Fundamentals of CS
Year 2020/2021
Faculty of Computers and Artificial Intelligence

Question 1:
Write a function for converting binary numbers to decimal ones. It should take the binary string as
an argument and return the decimal value.

Question2:
Given 2 strings s1 and s2, write a function to check if all the chars in the string1 are there in s2. Characters
position doesn’t matter. For example:
Input: S1= “pt” S2=”python”
Output: True
Input: s1=”lr” s2=”Fat”
Output: False

Question3:
Write a function to delete an element target from an array A of size N elements.
The specifications are:
• Inputs: A - an array, N size, target element
• Effects: The element target will be deleted from the array& all elements after the target will
be shifted one cell.
• Now the array size should be N-1
CS111: Fundamentals of CS
Year 2020/2021
Faculty of Computers and Artificial Intelligence
Question4:
Print the following pattern using “for loop” then write the same problem using “while loop”
*

**

***

****

*****

****

***

**

Question 5:
Write a program to find greatest common divisor (GCD) or highest common factor (HCF) of given two
numbers.
Input: N1, N2
Output: GCD

Question 6:
Write a Python program to sort a list of elements in an ascending order.
Input: “15, 40, 6, 99, 1, 5”
Output: “1, 5, 6, 15, 40, 99”
CS111: Fundamentals of CS
Year 2020/2021
Faculty of Computers and Artificial Intelligence
Question 7:

Write a Python program to take from the user three integer numbers (x,y, z) and send them as parameters to
function guessOperation.

The function should search about an operation (e.g., +, -,*,%, etc) that can be executed on both x and y
such that the result should be z, then it prints x operation y = z and return the operation as return value or z
if no operation found

Input: output
238 2**3 = 8

10 5 15 10+5 =15

Question 8:
Write a Python program to get the Fibonacci series between 0 to 50.
The Fibonacci Sequence is the series of numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21, ....
Every next number is found by adding up the two numbers before it.

Expected Output : 1 1 2 3 5 8 13 21 34

You might also like