CS256 – EXAM 1
1 Your current directory is /home. Create a new directory under todays date (nov11) and copy the file /home/nov7/answers.txt into the new directory you created.
2a 2 + 3 * 4 % (5 + 2 ) = 7
2b 165 mod 13 = 9
3 Write the output of the programs.
3a n = 90
while ( n >= 10):
if ( n % 20 == 0):
n = n – 10
80 60 40 20
3b a = ‘Hi’
b = a * 3
c = b + ‘How are you?’
d = c [0:6]
4 Write the output of the Program
str1 = ‘thIs exAM is onLY for practicING’
str2 = ‘Aa’
for ch in str1:
if not ch.islower() and ch not in str2 and not ch.isspace() :
5 Write down the final contents of the list. (Hint : A is less than a)
planets = [‘earth’,’mercury’,’Venus’,’Mars’]
planets. append ( ‘Jupiter’)
planets. sort ( )
planets. reverse ( )
mercury, earth, Venus, Mars
6 Write a program to read in 3 test scores. Take the highest two scores and calculate average score.
Print all the prime numbers between 0 to 100.
3 input statements
a = input(“Enter score 1”);
Write if else statements to get the biggest two.
Find the average.
Or you can put them in a list , sort it and take average from last two.
7 Write a Program to generate 10 random numbers between -100 and 100
Write a program to read in date of birth and make sure it is in mm/dd/yyyy format.
for i in range [0,11]:
i = random.randint(-100,101)
dob = raw_input(‘’);
length is 10
dob and dob is ‘’
dob[0:2] and dob [3:5] and dob[6:10] isdigit()
8 Write a Program to read in a file name. Open the file in read mode and count the number of characters, words and lines in the file.
9 Write a program using Visual Python module to:
> Assign a background color of your choice
> Create a ball at position (x , y , z)= ( -1, 1, 0) of radius = 0.5 and color of your choice.
> Create a Wall at position (x , y , z) = ( 3, 0, 0) of any size and color of your choice.
> Set the rate to 100 and make the ball to bounce off on the wall.
Write a program to define a Point Class, which has 2 attributes x-coordinate and y- coordinate. In the main function create 2 points(Instances of points) at (1.0, 1.0) and (5.0,1.0) and calculate the distance between them. (dist = sqrt( (x2-x1)^2 + (y2-y1)^2)
10 Bonus Question ( 5 points)
I love playing with strings and numbers. Can you understand my message?
Harry 0-2 Heaven 3-4 Gravity 2 Winnie 3-4 Advice 4-5 Doctor 0
Eat 1 Yummy 4
PLACE THIS ORDER OR A SIMILAR ORDER WITH US TODAY AND GET AN AMAZING DISCOUNT 🙂
Are you interested in this answer? Please click on the order button now to have your task completed by professional writers. Your submission will be unique and customized, so that it is totally plagiarism-free.