Relative Content

Tag Archive for cs50

I cant seem to find the issue in this cs 50 problem

def petrol(): while True: try: fract = input(‘Enter fraction here ‘) x , y = fract.split(‘/’) a = int(x) b = int(y) k = int(a*100/b) if 0<= k <=1: print(‘E’) if 1 <= k <=99: print(k,”%”, sep =”) if 99< k<=100: print(“F”) if k > 100: return False except (ValueError, ZeroDivisionError ,): pass I’m trying […]

I was doing the problem set2 for cs50x course, and while solving the caesar problem, i came across some unsual ouputs

#include<stdio.h> #include<cs50.h> #include<ctype.h> #include<string.h> int main(int argc,string argv[]){ if(argc==2) //to make sure there’s only one string after ./caesar { int digit=0,key=0; for(int i=0,n=strlen(argv[1]);i<n;i++) { if(argv[1][i]>=’0′ && argv[1][i]<=’9′) { digit= argv[1][i]-‘0′; key=key*10+digit; } else{ printf(“Usage: ./caesar keyn”); return 1; } } string text=get_string(“plainttext: “); printf(“ciphertext: “); key=key%26; for(int i=0,n=strlen(text);i<n;i++){ if(islower(text[i])) { text[i]=text[i]+key; if(text[i]>’Z’) { text[i]=text[i]-26; } […]

Need ans for SQL

On the left column are the movie titles, and on the right column are the actors’ names. I don’t know why these movies match only 4 times or 8 times and not other numbers, and why there is such a duplication. Thank u very muchenter image description here

cs50 week 6 dna incorrectly identifies sequence

I have been stuck on this for hours. When I run it it says this
dna.py exists
🙂 correctly identifies sequences/1.txt
🙂 correctly identifies sequences/2.txt
🙁 correctly identifies sequences/3.txt
expected “No matchn”, not “Bobn”
🙂 correctly identifies sequences/4.txt
🙂 correctly identifies sequences/5.txt
🙂 correctly identifies sequences/6.txt
🙁 correctly identifies sequences/7.txt
expected “Ronn”, not “Petunian”
🙂 correctly identifies sequences/8.txt
🙂 correctly identifies sequences/9.txt
🙂 correctly identifies sequences/10.txt
🙂 correctly identifies sequences/11.txt
🙂 correctly identifies sequences/12.txt
🙁 correctly identifies sequences/13.txt
expected “No matchn”, not “Petunian”
🙂 correctly identifies sequences/14.txt
🙂 correctly identifies sequences/15.txt
🙁 correctly identifies sequences/16.txt
expected “No matchn”, not “Albusn”
🙂 correctly identifies sequences/17.txt
🙁 correctly identifies sequences/18.txt
expected “No matchn”, not “Lavendern”
🙂 correctly identifies sequences/19.txt
🙂 correctly identifies sequences/20.txt